Plugin Directory

Changeset 2469873


Ignore:
Timestamp:
02/06/2021 12:25:10 AM (5 years ago)
Author:
gautierantoine
Message:

0.01.00.00

Location:
socials-ga/trunk
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • socials-ga/trunk/README.md

    r2456670 r2469873  
    11# gaplugin-socials
    2 === Socials - GA ===
     2=== GAPlugins - Socials ===
    33Author: Antoine GAUTIER
    44Author URI: gautierantoine.com
     
    88Tested up to: 5.5
    99Requires PHP: 7.2
    10 Stable tag: 0.00.02.02
     10Stable tag: 0.01.00.00
    1111License: GPLv3
    1212License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
  • socials-ga/trunk/gaplugin-socials-plugin.php

    r2456670 r2469873  
    11<?php
    22/**
    3  * @package Socials-GA
     3 * @package GAP-Socials
    44 */
    55/*
    6 Plugin Name: Socials-GA
    7 Plugin URI: https://github.com/Pepite61/gaplugin-socials
     6Plugin Name: GAP-Socials
     7Plugin URI: https://github.com/Gautier-Antoine/gaplugin-socials
    88Description: Plugin for your socials media
    9 Version: 0.00.02.02
     9Version: 0.01.00.00
    1010
    1111Requires at least: 5.2
  • socials-ga/trunk/includes/AdminSocials.php

    r2456656 r2469873  
    11<?php
    22/**
    3  * @package Socials-GA
     3 * @package GAP-Socials
    44 */
    55namespace GAPlugin;
     
    4444    * @var string name for the admin page
    4545    */
    46     ADMINPAGE = 'ga-admin-page';
     46    ADMINPAGE = 'gap-admin-page';
    4747
    4848  /**
     
    7171   */
    7272  public static function registerPublicScripts () {
    73     wp_register_style(static::FILE, static::getFolder() . 'includes/' . static::FILE . '.css');
    74     wp_enqueue_style(static::FILE);
     73    // wp_register_style(static::FILE);
     74    wp_enqueue_style(static::FILE, static::getFolder() . 'includes/' . static::FILE . '.css');
    7575  }
    7676
     
    8181  public static function AdminScripts($suffix) {
    8282      if ($suffix === (strtolower(static::MENU) . '_page_' . static::ADMINPAGE . '-' . static::PAGE)) {
    83           static::registerAdminScripts();
    84           }
     83        static::registerAdminScripts();
     84      }
    8585  }
    8686
     
    123123            static::ADMINPAGE,
    124124            [static::class,'GAPlugin_admin_page'],
    125             'dashicons-share',
     125            static::getFolder() . 'images/icon.svg',
     126            // 'dashicons-share',
    126127            30
    127128        );
     
    208209          <input
    209210            type="textarea"
    210             id="<?= $args['label_for'] ?>"
    211             name="<?= $option_name . '[' . $args['id'] . '][text]' ?>"
     211            id="<?= esc_attr( $args['label_for'] ) ?>"
     212            name="<?= esc_attr( $option_name ) . '[' . esc_attr( $args['id'] ) . '][text]' ?>"
    212213            class="textarea show-text"
    213214            title="<?php printf(__('Add some text before the links', static::LANGUAGE)) ?>"
    214             value="<?= $args['text'] ?>"
     215            value="<?= esc_attr( $args['text'] ) ?>"
    215216          ></input>
    216           <input type="hidden" name="<?= $option_name . '[' . $args['id'] . '][label_for]' ?>" value="<?= $args['label_for'] ?>"></input>
     217          <input type="hidden" name="<?= esc_attr( $option_name ) . '[' . esc_attr( $args['id'] ) . '][label_for]' ?>" value="<?= esc_attr( $args['label_for'] ) ?>"></input>
    217218        <?php
    218219    }
  • socials-ga/trunk/includes/Follow.php

    r2456473 r2469873  
    11<?php
    22/**
    3  * @package Socials-GA
     3 * @package GAP-Socials
    44 */
    55namespace GAPlugin;
     
    7373        ?>
    7474          <textarea
    75             name="<?= $option_name . '[' . $args['id'] . '][url]' ?>"
    76             id="<?= $args['label_for'] ?>"
     75            name="<?= esc_attr( $option_name ) . '[' . esc_attr( $args['id'] ) . '][url]' ?>"
     76            id="<?= esc_attr( $args['label_for'] ) ?>"
    7777            rows= "1"
    78             title="<?php printf(__('Put your %1$s URL', static::LANGUAGE), $args['label_for']) ?>"
     78            title="<?php printf( __('Put your %1$s URL', static::LANGUAGE), esc_attr( $args['label_for'] ) ) ?>"
    7979          ><?=
    80             esc_html( $args['url'] );
     80            esc_url( $args['url'] );
    8181          ?></textarea>
    82           <input type="hidden" name="<?= $option_name . '[' . $args['id'] . '][label_for]' ?>" value="<?= $args['label_for'] ?>"></input>
     82          <input type="hidden" name="<?= esc_attr( $option_name ) . '[' . esc_attr( $args['id'] ) . '][label_for]' ?>" value="<?= esc_attr( $args['label_for'] ) ?>"></input>
    8383        <?php
    8484    }
     
    8989    public static function ShortcodeNav() {
    9090        $option_name = static::getOptionName();
    91         echo '<div class="' . static::PAGE . '">';
     91        $shortcode = '<div class="' . static::PAGE . '">';
    9292        foreach ( get_option( $option_name ) as $id => $option ) {
    9393            if ( $id === 'settings' ) {
    9494              if (!empty( $option['text'] ) ) {
    95                 echo '<div class="' . static::PAGE . '-text">';
    96                   printf( $option['text'] );
    97                 echo '</div>';
     95              $shortcode .=  '<div class="' . static::PAGE . '-text">' .
     96                  esc_attr( $option['text'] )
     97              . '</div>';
    9898              }
    9999            } else {
     
    106106              }
    107107              if ( !empty ( $option['url'] ) ) {
    108                 echo '
     108                $shortcode .= '
    109109                  <a
    110110                    target="_blank"
    111                     title="' . __( 'Link to', static::LANGUAGE ) . ' ' . $option['label_for'] . '"
    112                     href="' . $link . esc_html( $option['url'] ) . '"
     111                    title="' . __( 'Link to', static::LANGUAGE ) . ' ' . esc_attr( $option['label_for'] ) . '"
     112                    href="' . $link . esc_url( $option['url'] ) . '"
    113113                  >
    114                     <div class="' . strtolower($option['label_for']) . '"></div>
     114                    <div class="' . strtolower( esc_attr( $option['label_for'] ) ) . '"></div>
    115115                  </a>
    116116                ';
     
    118118            }
    119119        }
    120         echo '</div>';
     120        $shortcode .= '</div>';
     121        return $shortcode;
    121122    }
    122123
     
    129130      $options = (get_option( $option_name )) ?: static::$list;
    130131      foreach ( $options as $id => $option ) {
    131         if ($id !== 'settings') {
    132           $title = static::PAGE . static::EXTENSION . '_' . strtolower($option['label_for']);
     132        if ( $id !== 'settings' ) {
     133          $title = static::PAGE . static::EXTENSION . '_' . strtolower( esc_attr( $option['label_for'] ) );
    133134          add_settings_field(
    134135            $title,
    135             $option['label_for'],
     136            esc_attr( $option['label_for'] ),
    136137            [static::class, 'addPageFunction'],
    137138            static::PAGE . static::EXTENSION, // Page
    138139            static::PAGE . static::EXTENSION . '_section',
    139140            [
    140               'label_for' => $option['label_for'],
    141               'url' => ($option['url']) ?: null,
    142               'id' => $id,
    143               'class' => strtolower($option['label_for'])
     141              'label_for' => esc_attr( $option['label_for'] ),
     142              'url' => ( esc_url( $option['url'] ) ) ?: null,
     143              'id' => esc_attr( $id ),
     144              'class' => strtolower( esc_attr( $option['label_for'] ) )
    144145            ]
    145146          );
    146147        } else {
    147             $title = static::PAGE . static::EXTENSION . '_' . strtolower($option['label_for']);
     148            $title = static::PAGE . static::EXTENSION . '_' . strtolower( esc_attr( $option['label_for'] ) );
    148149            add_settings_field(
    149150              $title,
    150               $option['label_for'],
     151              esc_attr( $option['label_for'] ),
    151152              [static::class, 'showText'],
    152153              static::PAGE . static::EXTENSION, // Page
    153154              static::PAGE . static::EXTENSION . '_section',
    154155              [
    155                 'label_for' => $option['label_for'],
    156                 'text' => ($option['text']) ?: null,
    157                 'id' => $id
     156                'label_for' => esc_attr( $option['label_for'] ),
     157                'text' => ( esc_attr( $option['text'] ) ) ?: null,
     158                'id' => esc_attr( $id )
    158159              ]
    159160            );
  • socials-ga/trunk/includes/Share.php

    r2456670 r2469873  
    11<?php
    22/**
    3  * @package Socials-GA
     3 * @package GAP-Socials
    44 */
    55namespace GAPlugin;
     
    5656    public static function addPageFunction( $args ) {
    5757        $option_name = static::getOptionName();
     58
     59        $checked = ( isset( $args['active'] ) && $args['active'] === '1' ) ? ' checked' : '';
    5860        ?>
    5961          <input
    6062            type="checkbox"
    6163            class="checkbox"
    62             id="<?= $args['label_for'] ?>"
    63             name="<?= $option_name . '[' . $args['id'] . '][active]' ?>"
    64             title="<?php printf(__('Checkbox for %1$s', static::LANGUAGE), $args['label_for']) ?>"
    65             <?php if ($args['active']) {echo ' checked';} ?>
     64            id="<?= esc_attr( $args['label_for'] ) ?>"
     65            name="<?= esc_attr( $option_name ) . '[' . esc_attr( $args['id'] ) . '][active]' ?>"
     66            title="<?php printf( __('Checkbox for %1$s', static::LANGUAGE), esc_attr( $args['label_for'] ) ) ?>"
     67            <?= $checked ?>
    6668          >
    6769        </td><td>
    68           <input type="hidden" name="<?= $option_name . '[' . $args['id'] . '][label_for]' ?>" value="<?= $args['label_for'] ?>"></input>
     70          <input type="hidden" name="<?= esc_attr( $option_name ) . '[' . esc_attr( $args['id'] ) . '][label_for]' ?>" value="<?= esc_attr( $args['label_for'] ) ?>"></input>
    6971        </td><td>
    70           <input type="hidden" name="<?= $option_name . '[' . $args['id'] . '][url]' ?>" value="<?= $args['url'] ?>"></input>
     72          <input type="hidden" name="<?= esc_attr( $option_name ) . '[' . esc_attr( $args['id'] ) . '][url]' ?>" value="<?= esc_url( $args['url'] ) ?>"></input>
     73        </td><td>
     74          <input type="hidden" name="<?= esc_attr( $option_name ) . '[' . esc_attr( $args['id'] ) . '][imgurl]' ?>" value="<?= esc_html( $args['imgurl'] ) ?>"></input>
     75        </td><td>
     76          <input type="hidden" name="<?= esc_attr( $option_name ) . '[' . esc_attr( $args['id'] ) . '][titleurl]' ?>" value="<?= esc_html( $args['titleurl'] ) ?>"></input>
    7177
    7278        <?php
     
    7884    public static function ShortcodeNav() {
    7985      $option_name = static::getOptionName();
    80       echo '<div class="' . static::PAGE . '">';
     86      $shortcode = '<div class="' . static::PAGE . '">';
    8187      foreach ( get_option( $option_name ) as $id => $option ) {
    8288        if ( $id === 'settings' ) {
    8389          if (!empty( $option['text'] ) ) {
    84             echo '<div class="' . static::PAGE . '-text">';
    85               printf( $option['text'] );
    86             echo '</div>';
     90            $shortcode .= '<div class="' . static::PAGE . '-text">' .
     91              esc_attr( $option['text'] )
     92            . '</div>';
    8793          }
    8894        } else {
    89           if ($option['active'] === true) {
     95          if ( $option['active'] === true ) {
     96          // var_dump ($option);
     97
    9098            $img = null;
    91             if ( isset($option['imgurl']) ) {
    92               $img = $option['imgurl'] . get_the_post_thumbnail_url(get_the_ID(),'full');
     99            if ( !empty( $option['imgurl'] ) && !empty( get_the_post_thumbnail_url( get_the_ID(), 'full' ) )) {
     100              $img =  $option['imgurl']  . get_the_post_thumbnail_url( get_the_ID(), 'full' );
    93101            }
    94102            $title = null;
    95             if ( isset($option['titleurl']) ) {
    96               $title = $option['titleurl'] . get_the_title();
     103            if ( !empty( $option['titleurl'] ) && !empty( get_the_title() ) ) {
     104              $title =  $option['titleurl'] . get_the_title();
    97105            }
    98             echo '
     106            $url = $option['url'] . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] .  $img  .  $title;
     107
     108            $shortcode .= '
    99109              <a
    100110                target="_blank"
    101                 title="' . __( 'Share this on', static::LANGUAGE ) . ' ' . $option['label_for'] . '"
    102                 href="' . $option['url'] . get_permalink() . $img . $title . '"
     111                title="' . __( 'Share this on', static::LANGUAGE ) . ' ' . esc_attr( $option['label_for'] ) . '"
     112                href="' . esc_url( $url ) . '"
    103113              >
    104                 <div class="' . strtolower($option['label_for']) . '"></div>
     114                <div class="' . strtolower( esc_attr( $option['label_for'] ) ) . '"></div>
    105115              </a>';
    106116          }
    107117        }
    108118      }
    109       echo '</div>';
     119      $shortcode .= '</div>';
     120      return $shortcode;
    110121    }
    111122
     
    116127     */
    117128    public static function getFields( $option_name ) {
    118       $options = (get_option( $option_name )) ?: static::$list;
     129      $options = ( get_option( $option_name ) ) ?: static::$list;
    119130      foreach ( $options as $id => $option ) {
    120131        if ($id !== 'settings') {
    121           $title = static::PAGE . static::EXTENSION . '_' . strtolower($option['label_for']);
     132          $title = static::PAGE . static::EXTENSION . '_' . strtolower( esc_attr( $option['label_for'] ) );
    122133          add_settings_field(
    123134            $title,
    124             $option['label_for'],
     135            esc_attr( $option['label_for'] ),
    125136            [static::class, 'addPageFunction'],
    126137            static::PAGE . static::EXTENSION, // Page
    127138            static::PAGE . static::EXTENSION . '_section',
    128139            [
    129               'label_for' => $option['label_for'],
    130               'url' => ($option['url']) ?: null,
    131               'active' => ($option['active']) ?: 0,
    132               'id' => $id,
    133               'class' => strtolower($option['label_for'])
     140              'label_for' => esc_attr( $option['label_for'] ),
     141              'url' => ($option['url']) ? esc_url( $option['url'] ) : null,
     142              'imgurl' => (!empty($option['imgurl'])) ? esc_html( $option['imgurl'] ) : false,
     143              'titleurl' => ( !empty( $option['titleurl'] ) ) ? esc_html( $option['titleurl'] ) : null,
     144              'active' => ($option['active']) ? esc_attr( $option['active'] ) : 0,
     145              'id' => esc_attr( $id ),
     146              'class' => strtolower( esc_attr( $option['label_for'] ) )
    134147            ]
    135148          );
    136149        } else {
    137           $title = static::PAGE . static::EXTENSION . '_' . strtolower($option['label_for']);
     150          $title = static::PAGE . static::EXTENSION . '_' . strtolower( esc_attr( $option['label_for'] ) );
    138151          add_settings_field(
    139152            $title,
    140             $option['label_for'],
     153            esc_attr( $option['label_for'] ),
    141154            [static::class, 'showText'],
    142155            static::PAGE . static::EXTENSION, // Page
    143156            static::PAGE . static::EXTENSION . '_section',
    144157            [
    145               'label_for' => $option['label_for'],
    146               'text' => ($option['text']) ?: null,
    147               'id' => $id
     158              'label_for' => esc_attr( $option['label_for'] ),
     159              'text' => ( $option['text'] ) ? esc_attr( $option['text'] ) : null,
     160              'id' => esc_attr( $id )
    148161            ]
    149162          );
     
    165178          $valid_input[$key]['label_for'] = sanitize_text_field( $option['label_for'] );
    166179          $valid_input[$key]['url'] = sanitize_url( $option['url'] );
    167           $valid_input[$key]['active'] = ( isset($option['active']) ) ? true : false;
     180          $valid_input[$key]['imgurl'] = ( isset( $option['imgurl'] ) ) ? wp_filter_post_kses( $option['imgurl'] ) : false;
     181          $valid_input[$key]['titleurl'] = ( isset( $option['titleurl'] ) ) ? wp_filter_post_kses( $option['titleurl'] ) : false;
     182          $valid_input[$key]['active'] = ( isset( $option['active'] ) ) ? true : false;
    168183        }
    169184      }
Note: See TracChangeset for help on using the changeset viewer.