Plugin Directory

Changeset 2549322


Ignore:
Timestamp:
06/17/2021 12:55:07 AM (5 years ago)
Author:
willfonkam
Message:

Updating trunk files to v.1.1

Location:
iaf-social-share/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • iaf-social-share/trunk/iaf-social-share.php

    r2308107 r2549322  
    1515// INCLUDES
    1616include( 'inc/activate.php' );
     17include( 'inc/deactivate.php' );
    1718include( 'inc/enqueue.php' );
    1819include( 'inc/admin/menu.php' );
     
    2425// HOOKS
    2526register_activation_hook( __FILE__, 'iaf_activate_plugin' );
     27register_deactivation_hook( __FILE__, 'iaf_deactivate_plugin' );
    2628add_action( 'wp_enqueue_scripts', 'iaf_enqueue' );
    2729add_action( 'admin_enqueue_scripts', 'iaf_admin_enqueue' );
  • iaf-social-share/trunk/inc/activate.php

    r2308107 r2549322  
    1313     */
    1414
    15     $iaf_opts          = get_option( 'iaf_social_share_opts' );
     15    $iaf_opts                           = get_option( 'iaf_social_share_opts' );
    1616
    1717    if( !$iaf_opts ){
    18         $opts                   = [
    19             'facebook'          => 'show',
    20             'twitter'           => 'show',
    21             'twitter_handle'    => 'wordpressdotcom',
    22             'linkedin'          => 'show',
    23             'whatsapp'          => 'show',
    24             'telegram'          => 'show',
    25             'before_content'    => 'hide',
    26             'after_content'     => 'show',
    27             'share_post'        => 'show',
    28             'share_page'        => 'hide',
    29             'share_archive'     => 'hide',
    30             'display'           => 'icon_and_text',
    31             'mobile'            => 'hide_text',
    32             'theme'             => 'default',
    33             'color'             => '#000000'
     18        $opts                           = [
     19            'facebook'                  => 'show',
     20            'twitter'                   => 'show',
     21            'twitter_handle'            => 'wordpressdotcom',
     22            'linkedin'                  => 'show',
     23            'whatsapp'                  => 'show',
     24            'telegram'                  => 'show',
     25            'before_content'            => 'hide',
     26            'after_content'             => 'show',
     27            'share_post'                => 'show',
     28            'share_page'                => 'hide',
     29            'share_archive'             => 'hide',
     30            'display'                   => 'icon_and_text',
     31            'mobile'                    => 'hide_text',
     32            'theme'                     => 'default',
     33            'color'                     => '#000000'
    3434        ];
     35
     36        $iaf_cpts                       = get_post_types( array( '_builtin' => false ), 'objects' );
     37        foreach( $iaf_cpts as $cpt ) {
     38            $opts['share_'.$cpt->name]  = 'show';
     39        }
    3540
    3641        add_option( 'iaf_social_share_opts', $opts );
  • iaf-social-share/trunk/inc/add-buttons.php

    r2308107 r2549322  
    77    $share_pages            = $iaf_opts['share_page'] == 'show' ? 'page' : '';
    88
    9     if( !is_singular( [ $share_posts, $share_pages ] ) ){
     9    $share_post_types       = [ $share_posts, $share_pages  ];
     10
     11    $iaf_cpts               = get_post_types( array( '_builtin' => false ), 'objects' );
     12    foreach( $iaf_cpts as $cpt ) {
     13        if( $iaf_opts['share_' . $cpt->name] == 'show' ) {
     14            array_push( $share_post_types, $cpt->name );
     15        }
     16    }
     17
     18    if( !is_singular( $share_post_types ) ){
    1019        return $content;
    1120    }
  • iaf-social-share/trunk/inc/admin/save-options.php

    r2308107 r2549322  
    44        wp_die( __( 'You don\'t have enough privilege to see this page' ) );
    55    }
     6
     7    echo '<pre>';
     8    var_dump( $_POST );
     9    echo '</pre>';
    610
    711    check_admin_referer( 'iaf_options_verify' );
     
    2428    $iaf_opts['color']                  = sanitize_hex_color( $_POST['iaf_custom_color'] );
    2529
     30    $iaf_cpts    = get_post_types( array( '_builtin' => false ), 'objects' );
     31    foreach( $iaf_cpts as $cpt ) {
     32        $iaf_opts['share_'.$cpt->name]  = sanitize_text_field( $_POST['iaf_share_' . $cpt->name] );
     33    }
     34
    2635    if( update_option( 'iaf_social_share_opts', $iaf_opts ) ) {
    2736        wp_redirect( admin_url( 'admin.php?page=iaf-social-share&status=1' ) );
     37        // echo 'OK';
    2838    } else {
    2939        wp_redirect( admin_url( 'admin.php?page=iaf-social-share&status=2' ) );
     40        // echo 'KO';
    3041    }
    31 
    32    
    3342}
  • iaf-social-share/trunk/inc/admin/sidebar-box.php

    r2308107 r2549322  
    4242            </div>
    4343        </div>
     44
     45        <?php
     46        $iaf_cpts    = get_post_types( array( '_builtin' => false ), 'objects' );
     47
     48        foreach( $iaf_cpts as $cpt ) {
     49            ?>
     50            <div class="iaf-form-row">
     51                <div class="iaf-form-label">
     52                    <?php esc_html_e( $cpt->label ); ?>
     53                </div><div class="iaf-form-control">
     54                    <div class="iaf-form-input">
     55                        <input type="radio" id="iaf_share_<?php echo $cpt->name; ?>_1" name="iaf_share_<?php echo $cpt->name; ?>"
     56                            <?php echo $iaf_opts['share_' . $cpt->name] == 'show' ? 'CHECKED' : '' ?> value="show" />
     57                        <label for="iaf_share_<?php echo $cpt->name; ?>_1"><?php _e( 'Show', 'iaf-social-share' ); ?></label>
     58                    </div>
     59                    <div class="iaf-form-input">
     60                        <input type="radio" id="iaf_share_<?php echo $cpt->name; ?>_2" name="iaf_share_<?php echo $cpt->name; ?>"
     61                            <?php echo $iaf_opts['share_' . $cpt->name] == 'hide' ? 'CHECKED' : '' ?> value="hide" />
     62                        <label for="iaf_share_<?php echo $cpt->name; ?>_2"><?php _e( 'Hide', 'iaf-social-share' ); ?></label>
     63                    </div>
     64                </div>
     65            </div>
     66            <?php
     67        }
     68        ?>
    4469
    4570    </div>
  • iaf-social-share/trunk/readme.txt

    r2510307 r2549322  
    55Requires PHP: 5.2.4
    66Tested up to: 5.7
    7 Stable tag: 1.0
     7Stable tag: 1.1
    88License: GPL2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3030= 1.0 =
    3131* Initial release
     32
     33= 1.1 =
     34* Share buttons can be added to custom post types
Note: See TracChangeset for help on using the changeset viewer.