Plugin Directory

Changeset 2969045


Ignore:
Timestamp:
09/20/2023 07:39:55 AM (3 years ago)
Author:
alian
Message:

Added new settings

Location:
astro-sticky-buttons/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • astro-sticky-buttons/trunk/astro-sticky-buttons-common.php

    r2968398 r2969045  
    2626    switch ($tab) {
    2727        case 'settings' :
     28            $option_names_enable = array();
     29
     30            $args = array( 'public' => true );
     31            $post_types = get_post_types( $args );
     32            foreach ($post_types as $post_type) {
     33                $option_names_enable[ASTRO_SB_PREFIX . 'enable_' . $post_type] = ASTRO_SB_PREFIX . 'enable_' . $post_type;
     34            }
     35
     36            $args = array( 'public' => true );
     37            $taxonomies = get_taxonomies( $args );
     38            foreach ($taxonomies as $taxonomy) {
     39                $option_names_enable[ASTRO_SB_PREFIX . 'enable_' . $taxonomy] = ASTRO_SB_PREFIX . 'enable_' . $taxonomy;
     40            }
     41
    2842            $option_names = array(
    2943                ASTRO_SB_PREFIX . 'email' => ASTRO_SB_PREFIX . 'email',
     
    4054                ASTRO_SB_PREFIX . 'pinterest' => ASTRO_SB_PREFIX . 'pinterest',
    4155            );
     56
     57            $option_names = array_merge($option_names_enable, $option_names);
    4258            break;
    4359
     
    8298 */
    8399function astro_sb_shortcode_output() {
     100
    84101    // Get the Template
    85102    $template_file = plugin_dir_path(__FILE__) . 'templates/astro-sticky-buttons.php';
     
    175192    return $str;
    176193}
     194
     195/**
     196 * Check the current page/post type.
     197 */
     198function astro_sb_get_current_post_type() {
     199    global $post;
     200
     201    //Default value
     202    $enable = false;
     203
     204    if ( is_singular() || is_single() || is_page() ) {
     205        $option_value = get_option('astro_sb_enable_' . $post->post_type);
     206        if ($option_value == 1) {
     207            $enable = true;
     208        }
     209    }
     210
     211    if ( is_category() || is_tax() || is_tag() ) {
     212        $obj = get_queried_object();
     213        if ($obj) {
     214            $term_taxonomy = $obj->taxonomy;
     215            $option_value = get_option('astro_sb_enable_' . $term_taxonomy);
     216            if ($option_value == 1) {
     217                $enable = true;
     218            }
     219        }
     220    }
     221
     222    if ( is_archive() ) {
     223        $enable = true;
     224    }
     225
     226    if ($enable) {
     227        echo astro_sb_shortcode_output();
     228    }else{
     229        return false;
     230    }
     231}
     232add_action('wp_footer', 'astro_sb_get_current_post_type');
  • astro-sticky-buttons/trunk/astro-sticky-buttons.php

    r2968398 r2969045  
    44 * Plugin URI:        https://wordpress.org/plugins/astro-sticky-buttons
    55 * Description:       Display your favourite sticky buttons to get in touch with your visitors and share your social channels.
    6  * Version:           1.0.1
     6 * Version:           1.1.0
    77 * Requires at least: 5.2
    88 * Requires PHP:      7.2
     
    8989    return $links;
    9090}
     91
     92/**
     93 * Activation check.
     94 */
     95register_activation_hook( __FILE__, 'astro_sb_check_plugin_version' );
     96function astro_sb_check_plugin_version() {
     97    $plugin_version = astro_sb_plugin_data('Version');
     98    if ($plugin_version < '1.0.2') {
     99        if (!isset($astro_sb_enable_all)) {
     100            add_option('astro_sb_enable_post', 1);
     101            add_option('astro_sb_enable_page', 1);
     102            add_option('astro_sb_enable_attachment', 1);
     103            return true;
     104        }
     105    }
     106}
  • astro-sticky-buttons/trunk/includes/tabs/tab-settings.php

    r2968398 r2969045  
    1111?>
    1212<div class="<?php echo $astro_sb_prefix . 'wrapper'; ?> <?php echo esc_attr( $option_group ); ?>">
    13 
    14     <div class="section-wrapper">
    15         <div class="section-wrapper-inner">
    16             <h2 id="settings" class="title"><?php _e('Settings', 'astro-sticky-buttons' ); ?></h2>
    17             <p><?php echo esc_html('Astro Sticky Buttons displays the sticky buttons using the shortcode:', 'astro-sticky-buttons'); ?> <strong>[astro-sticky-buttons]</strong><br>
    18                 <?php echo esc_html('To display the sticky buttons on all pages of the site, it is recommended to insert the shortcode in the header or footer of the site.', 'astro-sticky-buttons'); ?><br>
    19                 <?php echo esc_html('The shortcode can also be inserted via text widget.', 'astro-sticky-buttons'); ?></p>
    20         </div>
    21     </div>
    2213
    2314    <form method="post" action="options.php" class="<?php echo esc_attr($option_group); ?>_form">
     
    3021            <div class="section-wrapper-inner">
    3122
    32                 <h2 id="buttons" class="title"><?php _e('Buttons', 'astro-sticky-buttons' ); ?></h2>
     23                <p><?php echo esc_html('The sticky buttons can be displayed in two different methods:', 'astro-sticky-buttons'); ?>
     24                <ol>
     25                    <li><?php echo esc_html('Choose where to display the sticky buttons', 'astro-sticky-buttons'); ?> (<strong><?php echo esc_html('recommended', 'astro-sticky-buttons'); ?></strong>)</li>
     26                    <li><?php echo esc_html('Using the shortcode [astro-sticky-buttons] in your website content/widget/header/footer', 'astro-sticky-buttons'); ?></li>
     27                </ol>
     28                <p><strong><?php echo esc_html('It is recommended to use only one method!', 'astro-sticky-buttons'); ?></strong>
    3329
    3430                <hr>
    3531
    36                 <h3 id="buttons-communication" class="title"><?php _e('Chat/Communication', 'astro-sticky-buttons' ); ?></h3>
     32                <h2 id="where-display" class="title"><?php _e('Choose where to display the Astro Sticky Buttons', 'astro-sticky-buttons' ); ?></h2>
     33                <table class="form-table astro_sb_enable_disable_post_types">
     34                    <?php
     35                    $field_label = esc_html__( 'Check/Uncheck All', 'astro-sticky-buttons' );
     36                    $field_description = '';
     37                    $field_name = $astro_sb_prefix.'enable_disable_all';
     38                    $field_value = 1;
     39                    ?>
     40                    <tr>
     41                        <th scope="row"></th>
     42                        <td>
     43                            <input id="<?php echo esc_attr($field_name); ?>"
     44                                   name="<?php echo esc_attr($field_name); ?>"
     45                                   type="checkbox"
     46                                   class="<?php echo esc_attr($astro_sb_prefix) . 'checkbox_enable'; ?>"
     47
     48                            ><label for="<?php echo esc_attr($field_name); ?>"><?php echo esc_html($field_label); ?></label>
     49                        </td>
     50                    </tr>
     51
     52                    <?php
     53                    // Posts
     54                    $args = array( 'public' => true );
     55                    $post_types = get_post_types( $args );
     56
     57                    foreach ( $post_types  as $post_type ) {
     58                        $post_type = get_post_type_object($post_type);
     59
     60                        $field_label = esc_html__( 'Display in ' . $post_type->labels->name, 'astro-sticky-buttons' );
     61                        $field_description = '';
     62                        $field_name = $astro_sb_prefix.'enable_'.$post_type->name;
     63                        $field_value = get_option($field_name);
     64                        ?>
     65                        <tr>
     66                            <th scope="row"><label for="<?php echo esc_attr($field_name); ?>"><?php echo esc_html($field_label); ?></label></th>
     67                            <td>
     68                                <fieldset>
     69                                    <legend class="screen-reader-text"><span><?php echo esc_html($field_label); ?></span></legend>
     70                                    <label for="<?php echo esc_attr($field_name); ?>"><input id="<?php echo esc_attr($field_name); ?>"
     71                                                                                             name="<?php echo esc_attr($field_name); ?>"
     72                                                                                             type="checkbox"
     73                                                                                             class="<?php echo esc_attr($astro_sb_prefix) . 'checkbox_enable'; ?>"
     74                                                                                             value="1" <?php if ($field_value == "1") {
     75                                            echo 'checked="checked"';
     76                                        } ?>><?php echo esc_html($field_description); ?></label>
     77                                </fieldset>
     78                            </td>
     79                        </tr>
     80                        <?php
     81                    }
     82
     83                    // Taxonomies
     84                    $args = array( 'public' => true );
     85                    $taxonomies = get_taxonomies( $args );
     86
     87                    foreach ( $taxonomies  as $taxonomy ) {
     88                        $taxonomy = get_taxonomy($taxonomy);
     89
     90                        $field_label = esc_html__( 'Display in ' . $taxonomy->labels->name, 'astro-sticky-buttons' );
     91                        $field_description = '';
     92                        $field_name = $astro_sb_prefix.'enable_'.$taxonomy->name;
     93                        $field_value = get_option($field_name);
     94                        ?>
     95                        <tr>
     96                            <th scope="row"><label for="<?php echo esc_attr($field_name); ?>"><?php echo esc_html($field_label); ?></label></th>
     97                            <td>
     98                                <fieldset>
     99                                    <legend class="screen-reader-text"><span><?php echo esc_html($field_label); ?></span></legend>
     100                                    <label for="<?php echo esc_attr($field_name); ?>"><input id="<?php echo esc_attr($field_name); ?>"
     101                                                                                             name="<?php echo esc_attr($field_name); ?>"
     102                                                                                             type="checkbox"
     103                                                                                             class="<?php echo esc_attr($astro_sb_prefix) . 'checkbox_enable'; ?>"
     104                                                                                             value="1" <?php if ($field_value == "1") {
     105                                            echo 'checked="checked"';
     106                                        } ?>><?php echo esc_html($field_description); ?></label>
     107                                </fieldset>
     108                            </td>
     109                        </tr>
     110                        <?php
     111                    }
     112                    ?>
     113                </table>
     114
     115                <hr>
     116
     117                <h2 id="buttons-communication" class="title"><?php _e('Chat/Communication buttons', 'astro-sticky-buttons' ); ?></h2>
    37118                <table class="form-table">
    38119                    <?php
     
    120201                <hr>
    121202
    122                 <h3 id="buttons-communication" class="title"><?php _e('Social', 'astro-sticky-buttons' ); ?></h3>
     203                <h2 id="buttons-communication" class="title"><?php _e('Social buttons', 'astro-sticky-buttons' ); ?></h2>
    123204                <table class="form-table">
    124205
  • astro-sticky-buttons/trunk/js/astro-sticky-buttons-admin.js

    r2967221 r2969045  
    77    $('.colorpicker').wpColorPicker();
    88
     9    // Check/Uncheck to show/hide the sticky bar in post/taxonomy
     10    $("#astro_sb_enable_disable_all").click(function () {
     11        $(".astro_sb_checkbox_enable").prop('checked', $(this).prop('checked'));
     12    });
     13
     14    $(".astro_sb_checkbox_enable").change(function(){
     15        if (!$(this).prop("checked")){
     16            $("#astro_sb_enable_disable_all").prop("checked",false);
     17        }
     18    });
     19
    920});
  • astro-sticky-buttons/trunk/readme.txt

    r2968398 r2969045  
    44Requires at least: 5.2
    55Tested up to: 6.3.1
    6 Stable tag: 1.0.1
     6Stable tag: 1.1.0
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    1212Display your favourite sticky buttons to get in touch with your visitors and share your social channels.
    1313
    14 Chat/Communication buttons:
     14<strong>Chat/Communication buttons:</strong>
    1515<ul>
    1616<li>Email</li>
     
    2121</ul>
    2222
    23 Social buttons:
     23<strong>Social buttons:</strong>
    2424<ul>
    2525<li>Facebook</li>
     
    3232</ul>
    3333
     34<strong>Layout:</strong>
     35<ul>
     36<li>Position: it is possible to choose the position where to display the floating buttons bar: right, bottom-right, bottom, bottom-left, left</li>
     37<li>Icons: choose the distance beetween the icons, dimension, border and shape (squared and rounded) and box shadow</li>
     38</ul>
     39
    3440== Installation ==
    35411. Upload the entire `astro-sticky-buttons` folder to the `/wp-content/plugins/` directory.
     
    3743
    3844== Changelog ==
     45= 1.1.0 =
     46* Added new settings: it is possible to choose which post type or taxonomy as well as custom post type and custom taxonomy to display the sticky buttons bar (recommended method). Don't need to use the shortcode [astro-sticky-buttons] to display the sticky buttons bar.
     47
    3948= 1.0.1 =
    4049* Fix TikTok
Note: See TracChangeset for help on using the changeset viewer.