Plugin Directory

Changeset 3115915

Timestamp:
07/10/2024 10:09:00 PM (4 weeks ago)
Author:
maxpertici
Message:

MITYPES Button / trunk / 1.3

Location:
menu-item-types-button/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • menu-item-types-button/trunk/acf/button-field-group.php

    r2646961 r3115915  
    11<?php
    22
    3 defined( 'ABSPATH' ) or die();
    4 
    5 if( function_exists('acf_add_local_field_group') ){
    6 
    7 
    8     acf_add_local_field_group(array(
    9         'key' => 'group_mitypes_button_61b136d8bcf78',
    10         'title' => __( 'Button', 'mitypes-button' ),
    11         'fields' => array(
     3return array(
     4   
     5    'key' => 'group_mitypes_button_61b136d8bcf78',
     6    'title' => __( 'Button', 'mitypes-button' ),
     7    'fields' => array(
     8        array(
     9            'key' => 'field_mitypes_button_61b136ec53e37',
     10            'label' => 'URL',
     11            'name' => 'mitypes_button_url',
     12            'type' => 'url',
     13            'instructions' => '',
     14            'required' => 0,
     15            'conditional_logic' => 0,
     16            'wrapper' => array(
     17                'width' => '',
     18                'class' => '',
     19                'id' => '',
     20            ),
     21            'default_value' => '',
     22            'placeholder' => '',
     23        ),
     24        array(
     25            'key' => 'field_mitypes_button_61b1370d53e38',
     26            'label' => __( 'Button Target', 'mitypes-button' ),
     27            'name' => 'mitypes_button_target_blank',
     28            'type' => 'true_false',
     29            'instructions' => '',
     30            'required' => 0,
     31            'conditional_logic' => 0,
     32            'wrapper' => array(
     33                'width' => '',
     34                'class' => '',
     35                'id' => '',
     36            ),
     37            'message' => __( 'Open link in new tab', 'mitypes-button' ),
     38            'default_value' => 0,
     39            'ui' => 0,
     40            'ui_on_text' => '',
     41            'ui_off_text' => '',
     42        ),
     43    ),
     44    'location' => array(
     45        array(
    1246            array(
    13                 'key' => 'field_mitypes_button_61b136ec53e37',
    14                 'label' => 'URL',
    15                 'name' => 'mitypes_button_url',
    16                 'type' => 'url',
    17                 'instructions' => '',
    18                 'required' => 0,
    19                 'conditional_logic' => 0,
    20                 'wrapper' => array(
    21                     'width' => '',
    22                     'class' => '',
    23                     'id' => '',
    24                 ),
    25                 'default_value' => '',
    26                 'placeholder' => '',
    27             ),
    28             array(
    29                 'key' => 'field_mitypes_button_61b1370d53e38',
    30                 'label' => __( 'Button Target', 'mitypes-button' ),
    31                 'name' => 'mitypes_button_target_blank',
    32                 'type' => 'true_false',
    33                 'instructions' => '',
    34                 'required' => 0,
    35                 'conditional_logic' => 0,
    36                 'wrapper' => array(
    37                     'width' => '',
    38                     'class' => '',
    39                     'id' => '',
    40                 ),
    41                 'message' => __( 'Open link in new tab', 'mitypes-button' ),
    42                 'default_value' => 0,
    43                 'ui' => 0,
    44                 'ui_on_text' => '',
    45                 'ui_off_text' => '',
     47                'param' => 'mitypes',
     48                'operator' => '==',
     49                'value' => 'button',
    4650            ),
    4751        ),
    48         'location' => array(
    49             array(
    50                 array(
    51                     'param' => 'mitypes',
    52                     'operator' => '==',
    53                     'value' => 'button',
    54                 ),
    55             ),
    56         ),
    57         'menu_order' => 0,
    58         'position' => 'normal',
    59         'style' => 'default',
    60         'label_placement' => 'top',
    61         'instruction_placement' => 'label',
    62         'hide_on_screen' => '',
    63         'active' => true,
    64         'description' => '',
    65         'show_in_rest' => 0,
    66     ));
    67 
    68 }
     52    ),
     53    'menu_order' => 0,
     54    'position' => 'normal',
     55    'style' => 'default',
     56    'label_placement' => 'top',
     57    'instruction_placement' => 'label',
     58    'hide_on_screen' => '',
     59    'active' => true,
     60    'description' => '',
     61    'show_in_rest' => 0,
     62) ;
  • menu-item-types-button/trunk/menu-item-types-button.php

    r2828227 r3115915  
    44Plugin URI:   https://maxpertici.fr#menu-item-types
    55Description:  Add the ability to use buttons in your nav menu
    6 Version:      1.2
     6Version:      1.
    77Author:       @maxpertici
    88Author URI:   https://maxpertici.fr
     
    1818
    1919/**
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
    2050 * Run plugin - test
    2151 * @since 1.0
     
    2353
    2454function mitypes_button_run(){
    25 
    2655    if( ! mitypes_button_is_mitypes_loaded() ){
    2756        add_action('admin_notices', 'mitypes_button_notice_plugin_required');
    2857    }
    29 
    30    
    3158}
    3259
    3360add_action( 'plugins_loaded', 'mitypes_button_run' );
    34 
    35 
    36 
    37 /**
    38  * Add custom nav menu item
    39  */
    40 function mitypes_button_add_item_types( $types ){
    41     $types[] = array(
    42         'slug'        => "button",
    43         'icon'        => plugin_dir_url( __FILE__ ) . 'img/mitypes-button.svg',
    44         'label'       => __( 'Button', 'mitypes-button' ),
    45         'field-group' => plugin_dir_path( __DIR__ ) . 'menu-item-types-button/acf/button-field-group.php',
    46         'render'      => plugin_dir_path( __DIR__ ) . 'menu-item-types-button/render/button.php',
    47     );
    48     return $types;
    49 }
    50 
    51 add_filter( 'mitypes_item_types', 'mitypes_button_add_item_types' );
    52 
    53 
    54 
    55 /**
    56  * Handle attributes : skip href
    57  */
    58 
    59 function mitypes_button_attributes_skiper( $atts, $item, $args, $depth, $custom_item_type ){
    60     if( ( 'button' === $custom_item_type ) ){ unset( $atts['href'] ); }
    61     return $atts ;
    62 }
    63 
    64 add_filter( 'mitypes_nav_menu_link_attributes', 'mitypes_button_attributes_skiper', 11, 5 );
    6561
    6662
  • menu-item-types-button/trunk/readme.txt

    r2828227 r3115915  
    44Tags: Menu, Custom, Nav item, Button, CTA
    55Requires at least: 5.8
    6 Tested up to: 6.1
    7 Stable tag: 1.2
     6Tested up to: 6.
     7Stable tag: 1.
    88Requires PHP: 7.0
    99License: GPLv2
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1111
     12
    1213
    1314== Description ==
     
    3637== Changelog ==
    3738
     39
     40
     41
     42
     43
    3844= 1.2 =
    3945* Version bump
  • menu-item-types-button/trunk/render/button.php

    r2646961 r3115915  
    2121
    2222$target = '_self' ;
    23 
    24 if( isset( $blank ) && '1' === $blank ){ $target = '_blank' ; }
     23if( isset( $blank ) && ( '1' === $blank || true === $blank ) ){ $target = '_blank' ; }
    2524
    2625echo wp_kses( $args->before, $a_tags );
Note: See TracChangeset for help on using the changeset viewer.