Plugin Directory

Changeset 3148731


Ignore:
Timestamp:
09/09/2024 01:43:35 PM (18 months ago)
Author:
crazypsycho
Message:

1.4.0

  • Add singular/plural for post-types
  • Add human-readable and translated for user-roles
  • Add wrapper-option for user-role
  • Fix possible error with woocommerce is-featured
  • Post-Parent can now return title and name
Location:
dynamictags
Files:
66 added
10 edited

Legend:

Unmodified
Added
Removed
  • dynamictags/trunk/Lib/DynamicTags/AcfRepeater.php

    r3145303 r3148731  
    5959            'ids' => 'IDs',
    6060            'urls' => 'Urls',
    61             'img' => __( 'Rendered <img>' ),
    62             'array' => __( 'Array (for use in gallery-widget)' ),
     61            'img' => __( 'Rendered <img>', 'dynamic-tags' ),
     62            'array' => __( 'Array (for use in gallery-widget)', 'dynamic-tags' ),
    6363        ];
    6464
     
    286286            }
    287287
    288             $has_option_page_location = in_array( $acfGroup['ID'], $optionsPageGroupsIds, true );
    289             $is_only_options_page = $has_option_page_location && 1 === count( $acfGroup['location'] );
     288            $hasOptionPageLocation = in_array( $acfGroup['ID'], $optionsPageGroupsIds, true );
     289            $isOnlyOptionsPage = $hasOptionPageLocation && 1 === count( $acfGroup['location'] );
    290290
    291291            foreach ( $fields as $field ) {
     
    303303                    }
    304304                    // Use group ID for unique keys
    305                     if ( $has_option_page_location ) {
     305                    if ( $hasOptionPageLocation ) {
    306306                        $key = 'options:' . $field['name'];
    307307                        $options[$key] = __( 'Options', 'elementor-pro' ) . ':' . $field['label'];
    308                         if ( $is_only_options_page ) {
     308                        if ( $isOnlyOptionsPage ) {
    309309                            continue;
    310310                        }
  • dynamictags/trunk/Lib/DynamicTags/Cookies.php

    r2509935 r3148731  
    1010    use ElementBase;
    1111
    12     public function get_name() {
     12    public function get_name(): string {
    1313        return 'dynamic-tags-cookies';
    1414    }
    1515
    16     public function get_title() {
     16    public function get_title(): string {
    1717        return __( 'Cookies', 'dynamic-tags' );
    1818    }
    1919
    2020
    21     public function get_group() {
     21    public function get_group(): array {
    2222        return [ Module::SITE_GROUP ];
    2323    }
    2424
    25     public function get_categories() {
     25    public function get_categories(): array {
    2626        return [ Module::TEXT_CATEGORY ];
    2727    }
    2828
    29     protected function register_controls() {
     29    protected function register_controls(): void {
    3030        $this->add_control(
    3131            'CookieName',
     
    3939            ]
    4040        );
     41
     42        $this->add_control(
     43            'CustomCookieName',
     44            [
     45                'label' => __( 'Custom Cookie Name', 'dynamic-tags' ),
     46                'type' => Controls_Manager::TEXT,
     47                'label_block' => true,
     48                'default' => '',
     49            ]
     50        );
    4151    }
    4252
    43     public function render() {
     53    public function render(): void {
    4454        $settings = $this->get_settings();
     55        $customKey = $settings['CustomCookieName'];
     56        if ( !empty( $customKey ) ) {
     57            $value = filter_input( INPUT_COOKIE, $customKey );
     58            echo wp_kses_post( $value );
     59            return;
     60        }
     61
    4562        $key = $settings['CookieName'];
    4663        $value = filter_input( INPUT_COOKIE, $key );
  • dynamictags/trunk/Lib/DynamicTags/PodsExtended.php

    r3145303 r3148731  
    99use ElementorPro\Modules\DynamicTags\Pods\Tags\Pods_Text;
    1010
    11 class PodsExtended extends Pods_Text {
    12     use ElementBase;
     11if ( function_exists( 'pods_api' ) ) {
     12    class PodsExtended extends Pods_Text {
     13        use ElementBase;
    1314
    14     public function get_name(): string {
    15         return 'dynamic-tags-pods-extended';
     15        public function get_name(): string {
     16            return 'dynamic-tags-pods-extended';
     17        }
     18
     19        public function get_title(): string {
     20            return parent::get_title() . ' Extended';
     21        }
     22
     23        protected function get_supported_fields(): array {
     24            $fields = parent::get_supported_fields();
     25            $fields[] = 'boolean';
     26
     27            return $fields;
     28        }
    1629    }
    17 
    18 
    19     public function get_title(): string {
    20         return parent::get_title() . ' Extended';
    21     }
    22 
    23 
    24     protected function get_supported_fields() {
    25         $fields = parent::get_supported_fields();
    26         $fields[] = 'boolean';
    27 
    28         return $fields;
    29     }
    30 
    3130}
  • dynamictags/trunk/Lib/DynamicTags/PostParent.php

    r2509935 r3148731  
    44
    55use DynamicTags\Lib\ElementBase;
     6use Elementor\Controls_Manager;
    67use Elementor\Core\DynamicTags\Tag;
    78use ElementorPro\Modules\DynamicTags\Module;
     
    1415    use ElementBase;
    1516
    16     public function get_name() {
     17    public function get_name(): string {
    1718        return 'dynamic-tags-post-parent';
    1819    }
    1920
    20     public function get_title() {
     21    public function get_title(): string {
    2122        return __( 'Post Parent', 'elementor-pro' );
    2223    }
    2324
    24     public function get_group() {
     25    public function get_group(): string {
    2526        return Module::POST_GROUP;
    2627    }
    2728
    28     public function get_categories() {
     29    public function get_categories(): array {
    2930        return [ Module::TEXT_CATEGORY ];
    3031    }
    3132
    32     public function render() {
     33    protected function register_controls(): void {
     34        $this->add_control(
     35            'output',
     36            [
     37                'label' => __( 'Output', 'dynamic-tags' ),
     38                'type' => Controls_Manager::SELECT,
     39                'label_block' => true,
     40                'default' => 'id',
     41                'options' => [
     42                    'id' => 'ID',
     43                    'post_title' => __('Post-Title', 'dynamic-tags'),
     44                    'post_name' => __('Post-Name', 'dynamic-tags'),
     45                ],
     46            ]
     47        );
     48    }
     49
     50    public function render(): void {
    3351        $post = get_post();
    3452
     
    3755        }
    3856
    39         echo $post->post_parent;
     57        switch ($this->get_settings('output')) {
     58            case 'post_title':
     59                echo get_the_title($post->post_parent);
     60                break;
     61            case 'post_name':
     62                $parent = get_post($post->post_parent);
     63                echo !empty($parent) ? $parent->post_name : '';
     64                break;
     65            case 'id':
     66            default:
     67                echo $post->post_parent;
     68                break;
     69        }
     70    }
     71
     72    public function get_panel_template_setting_key(): string {
     73        return 'output';
    4074    }
    4175}
  • dynamictags/trunk/Lib/DynamicTags/Session.php

    r2509935 r3148731  
    1010    use ElementBase;
    1111
    12     public function get_name() {
     12    public function get_name(): string {
    1313        return 'dynamic-tags-session';
    1414    }
    1515
    16     public function get_title() {
     16    public function get_title(): string {
    1717        return __( 'Session', 'dynamic-tags' );
    1818    }
    1919
    2020
    21     public function get_group() {
     21    public function get_group(): array {
    2222        return [ Module::SITE_GROUP ];
    2323    }
    2424
    25     public function get_categories() {
     25    public function get_categories(): array {
    2626        return [ Module::TEXT_CATEGORY ];
    2727    }
    2828
    29     protected function register_controls() {
     29    protected function register_controls(): void {
    3030        $this->add_control(
    3131            'SessionKey',
     
    3737            ]
    3838        );
     39
     40        $this->add_control(
     41            'CustomSessionKey',
     42            [
     43                'label' => __( 'Custom Session Key', 'dynamic-tags' ),
     44                'type' => Controls_Manager::TEXT,
     45                'label_block' => true,
     46                'default' => '',
     47            ]
     48        );
    3949    }
    4050
    41     public function render() {
     51    public function render(): void {
    4252        $settings = $this->get_settings();
     53
     54        $customKey = $settings['CustomSessionKey'];
     55        if ( !empty( $customKey ) ) {
     56            $value = filter_var( $_SESSION[$customKey] ?? '' );
     57            echo wp_kses_post( $value );
     58            return;
     59        }
     60
    4361        $key = $settings['SessionKey'];
    4462        if ( empty( $key ) || empty( $_SESSION[$key] ) ) {
  • dynamictags/trunk/Lib/DynamicTags/UserRole.php

    r3145303 r3148731  
    5858            ]
    5959        );
     60
     61        $this->add_control(
     62            'format',
     63            [
     64                'label' => __( 'Format', 'dynamic-tags' ),
     65                'type' => Controls_Manager::SELECT,
     66                'label_block' => true,
     67                'default' => 'plain',
     68                'options' => [
     69                    'plain' => 'Plain',
     70                    'human_readable' => 'Human readable',
     71                    'translated' => 'Translated',
     72                ],
     73            ]
     74        );
     75
     76        $this->add_control(
     77            'addWrapper',
     78            [
     79                'label' => __( 'Add wrapper around items', 'dynamic-tags' ),
     80                'type' => Controls_Manager::SWITCHER,
     81                'default' => 'no',
     82            ]
     83        );
    6084    }
    6185
     
    78102        $separator = $this->get_settings( 'separator' ) ?? '';
    79103        $userInfo = get_userdata( $userId );
    80         $userRoles = implode( $separator, $userInfo->roles );
     104
     105
     106        switch ($this->get_settings('format')) {
     107            case 'human_readable':
     108                global $wp_roles;
     109                $roles = $wp_roles->get_names();
     110                $rolesArray = [];
     111                foreach ($userInfo->roles as $role) {
     112                    $rolesArray[] = $roles[$role];
     113                }
     114                break;
     115            case 'translated':
     116                global $wp_roles;
     117                $roles = $wp_roles->get_names();
     118                $rolesArray = [];
     119                foreach ($userInfo->roles as $role) {
     120                    $rolesArray[] = translate_user_role($roles[$role]);
     121                }
     122
     123                break;
     124            case 'plain':
     125            default:
     126                $rolesArray = $userInfo->roles;
     127                break;
     128        }
     129
     130        if ($this->get_settings('addWrapper') === 'yes') {
     131            foreach ($rolesArray as &$role) {
     132                $role = '<span class="user-role">' . $role . '</span>';
     133            }
     134        }
     135       
     136        $userRoles = implode( $separator, $rolesArray );
     137
    81138        echo $userRoles;
    82139    }
    83140
     141    public function get_panel_template_setting_key(): string {
     142        return 'key';
     143    }
    84144}
  • dynamictags/trunk/Lib/DynamicTags/WidgetContent.php

    r3145303 r3148731  
    5252
    5353        $postList = [];
    54         foreach ($allPosts as $post) {
    55             $postList[$post->ID] = ($post->post_title ?? $post->post_name) . " ($post->ID)";
     54        foreach ( $allPosts as $post ) {
     55            $postList[$post->ID] = ( $post->post_title ?? $post->post_name ) . " ($post->ID)";
    5656        }
    5757
     
    6464                'options' => $postList,
    6565                'default' => '',
    66                 'render_type' => 'ui'
     66                'render_type' => 'ui',
    6767            ]
    6868        );
    69         $this->add_control('post-id',
    70         [
    71             'label' => __( 'Post ID' ),
    72             'type' => Controls_Manager::TEXT,
    73             'label_block' => false,
    74             'default' => '',
    75         ]
     69        $this->add_control( 'post-id',
     70            [
     71                'label' => __( 'Post ID', 'dynamic-tags' ),
     72                'type' => Controls_Manager::TEXT,
     73                'label_block' => false,
     74                'default' => '',
     75            ]
    7676        );
    7777        $this->add_control(
    7878            'dynamic-tags-widget-id-select',
    7979            [
    80                 'label' => __( 'Widget' ),
     80                'label' => __( 'Widget', 'dynamic-tags' ),
    8181                'type' => Controls_Manager::SELECT,
    8282                'label_block' => false,
    8383                'options' => [],
    8484                'default' => '',
    85                 'render_type' => 'ui'
     85                'render_type' => 'ui',
    8686            ]
    8787        );
     
    8989            'widget-id',
    9090            [
    91                 'label' => __( 'Widget ID' ),
     91                'label' => __( 'Widget ID', 'dynamic-tags' ),
    9292                'type' => Controls_Manager::TEXT,
    9393                'label_block' => false,
  • dynamictags/trunk/Lib/DynamicTags/WooCommerceIsFeatured.php

    r2509935 r3148731  
    1010    use ElementBase;
    1111
    12     public function get_name() {
     12    public function get_name(): string {
    1313        return 'dynamic-tags-woocommerce-visibility';
    1414    }
    1515
    16     public function get_title() {
     16    public function get_title(): string {
    1717        return __( 'WooCommerce is a featured product', 'dynamic-tags' );
    1818    }
    1919
    20     public function get_categories() {
     20    public function get_categories(): array {
    2121        return [ Module::TEXT_CATEGORY ];
    2222    }
    2323
    24     protected function register_controls() {
     24    protected function register_controls(): void {
    2525
    2626    }
    2727
    28     public function get_group() {
     28    public function get_group(): array {
    2929        if ( !class_exists( 'WooCommerce' ) ) {
    30             return '';
     30            return [];
    3131        }
    3232        return [ Module::POST_GROUP ];
    3333    }
    3434
    35     public function render() {
     35    public function render(): void {
    3636        if ( !function_exists( 'wc_get_product' ) ) {
    3737            return;
    3838        }
    39         $product = wc_get_product();
    40         echo $product->is_featured();
     39        $post = get_post();
     40        $product = wc_get_product( $post );
     41        if ( !empty( $product ) ) {
     42            echo $product->is_featured();
     43        }
    4144    }
    4245}
  • dynamictags/trunk/README.txt

    r3145303 r3148731  
    55Requires at least: 5.0
    66Tested up to: 6.6
    7 Stable tag: 1.3.0
     7Stable tag: 1.4.0
    88Requires PHP: 7.4
    99License: GPLv2 or later
     
    5454
    5555== Changelog ==
     56= 1.4.0 =
     57* Add singular/plural for post-types
     58* Add human-readable and translated for user-roles
     59* Add wrapper-option for user-role
     60* Fix possible error with woocommerce is-featured
     61* Post-Parent can now return title and name
     62
    5663= 1.3.0 =
    5764* Add acf-repeater tag
  • dynamictags/trunk/dynamic-tags.php

    r3145303 r3148731  
    1212 * Plugin URI:        https://github.com/RTO-Websites/dynamic-tags/
    1313 * Description:       Dynamic Tags is an Elementor addon that adds some useful dynamic tags.
    14  * Version:           1.3.0
     14 * Version:           1.4.0
    1515 * Author:            RTO GmbH
    1616 * Author URI:        https://www.rto.de
     
    2626}
    2727
    28 define( 'DynamicTags_VERSION', '1.3.0' );
     28define( 'DynamicTags_VERSION', '1.4.0' );
    2929
    3030define( 'DynamicTags_DIR', str_replace( '\\', '/', __DIR__ ) );
Note: See TracChangeset for help on using the changeset viewer.