Plugin Directory

Changeset 2456670


Ignore:
Timestamp:
01/15/2021 12:08:58 AM (5 years ago)
Author:
gautierantoine
Message:

0.00.02.02

Location:
socials-ga/trunk
Files:
5 edited

Legend:

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

    r2456662 r2456670  
    88Tested up to: 5.5
    99Requires PHP: 7.2
    10 Stable tag: 0.00.02.01
     10Stable tag: 0.00.02.02
    1111License: GPLv3
    1212License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
  • socials-ga/trunk/gaplugin-socials-plugin.php

    r2456662 r2456670  
    77Plugin URI: https://github.com/Pepite61/gaplugin-socials
    88Description: Plugin for your socials media
    9 Version: 0.00.02.01
     9Version: 0.00.02.02
    1010
    1111Requires at least: 5.2
  • socials-ga/trunk/includes/Share.php

    r2456656 r2456670  
    11<?php
     2/**
     3 * @package Socials-GA
     4 */
    25namespace GAPlugin;
    36/**
     
    58* manage the social media where we can share the article in your Share ShortcodeNav
    69*/
    7 class Share extends AdminPage {
    8   const
     10class Share extends AdminSocials {
     11
     12    const
     13      /**
     14      * @var string name of the page
     15      */
     16      PAGE = 'share',
     17      /**
     18      * @var string name for the option
     19      */
     20      OPTION = 'gap_share';
     21
    922    /**
    10     * @var string name of the page
     23    * @var array names of the share social medias and urls
    1124    */
    12     PAGE = 'share',
     25    public static $list = [
     26      'settings' => ['label_for' => 'Text before', 'text' => ''],
     27      0 =>  ['label_for' => 'FaceBook', 'url' => 'https://www.facebook.com/sharer/sharer.php?u=', 'active' => 0],
     28      1 =>  ['label_for' => 'Twitter', 'url' => 'https://twitter.com/share?url=', 'active' => 0],
     29      2 =>  [
     30          'label_for' => 'Pinterest', 'url' => 'http://pinterest.com/pin/create/button/?url=',
     31          'imgurl' => '&amp;media=',
     32          'titleurl' => '&amp;description=',
     33          'active' => 0
     34        ],
     35      3 =>  ['label_for' => 'WhatsApp', 'url' => 'https://wa.me/?text=', 'active' => 0],
     36      4 =>  ['label_for' => 'Telegram', 'url' => 'https://t.me/share/url?url=', 'active' => 0],
     37      5 =>  ['label_for' => 'Email', 'url' => 'mailto:?body=', 'active' => 0]
     38        // CSS ready: insta,Map, Youtube, Twitch, linkedin, vimeo, github, WeChat, Tumblr, Viber, Snapchat, flipboard
     39    ];
     40
    1341    /**
    14     * @var string name of the language file
     42     * Text to display with the settings section
     43     */
     44    public static function registerSettingsText () {
     45      printf(
     46        __( 'Which social media do you want to share with your visitors', static::LANGUAGE ) . '<br>' .
     47        __( 'You can reorder them too', static::LANGUAGE ) .
     48        '<br>Shortcode = [GAP-' . static::PAGE . ']'
     49      );
     50    }
     51
     52    /**
     53    * Create Admin Page Functions for each field
     54    * @param array $args list from registerSettings()
    1555    */
    16     LANGUAGE = 'share-socials-text',
     56    public static function addPageFunction( $args ) {
     57        $option_name = static::getOptionName();
     58        ?>
     59          <input
     60            type="checkbox"
     61            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';} ?>
     66          >
     67        </td><td>
     68          <input type="hidden" name="<?= $option_name . '[' . $args['id'] . '][label_for]' ?>" value="<?= $args['label_for'] ?>"></input>
     69        </td><td>
     70          <input type="hidden" name="<?= $option_name . '[' . $args['id'] . '][url]' ?>" value="<?= $args['url'] ?>"></input>
     71
     72        <?php
     73    }
     74
    1775    /**
    18     * @var string name for the files
    19     */
    20     FILE = 'share-socials',
     76     * Create ShortCode
     77     */
     78    public static function ShortcodeNav() {
     79      $option_name = static::getOptionName();
     80      echo '<div class="' . static::PAGE . '">';
     81      foreach ( get_option( $option_name ) as $id => $option ) {
     82        if ( $id === 'settings' ) {
     83          if (!empty( $option['text'] ) ) {
     84            echo '<div class="' . static::PAGE . '-text">';
     85              printf( $option['text'] );
     86            echo '</div>';
     87          }
     88        } else {
     89          if ($option['active'] === true) {
     90            $img = null;
     91            if ( isset($option['imgurl']) ) {
     92              $img = $option['imgurl'] . get_the_post_thumbnail_url(get_the_ID(),'full');
     93            }
     94            $title = null;
     95            if ( isset($option['titleurl']) ) {
     96              $title = $option['titleurl'] . get_the_title();
     97            }
     98            echo '
     99              <a
     100                target="_blank"
     101                title="' . __( 'Share this on', static::LANGUAGE ) . ' ' . $option['label_for'] . '"
     102                href="' . $option['url'] . get_permalink() . $img . $title . '"
     103              >
     104                <div class="' . strtolower($option['label_for']) . '"></div>
     105              </a>';
     106          }
     107        }
     108      }
     109      echo '</div>';
     110    }
     111
    21112    /**
    22     * @var string name for the plugin folder
    23     */
    24     FOLDER = 'gaplugin-socials';
     113     * Create Fields for the admin page
     114     *
     115     * @param string $option_name
     116     */
     117    public static function getFields( $option_name ) {
     118      $options = (get_option( $option_name )) ?: static::$list;
     119      foreach ( $options as $id => $option ) {
     120        if ($id !== 'settings') {
     121          $title = static::PAGE . static::EXTENSION . '_' . strtolower($option['label_for']);
     122          add_settings_field(
     123            $title,
     124            $option['label_for'],
     125            [static::class, 'addPageFunction'],
     126            static::PAGE . static::EXTENSION, // Page
     127            static::PAGE . static::EXTENSION . '_section',
     128            [
     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'])
     134            ]
     135          );
     136        } else {
     137          $title = static::PAGE . static::EXTENSION . '_' . strtolower($option['label_for']);
     138          add_settings_field(
     139            $title,
     140            $option['label_for'],
     141            [static::class, 'showText'],
     142            static::PAGE . static::EXTENSION, // Page
     143            static::PAGE . static::EXTENSION . '_section',
     144            [
     145              'label_for' => $option['label_for'],
     146              'text' => ($option['text']) ?: null,
     147              'id' => $id
     148            ]
     149          );
     150        }
     151      }
     152    }
    25153
    26     public static function getfolder(){
    27       return plugin_dir_url( __DIR__ );
     154    /**
     155     * Sanitize POST data from custom settings form
     156     *
     157     * @param array $input Contains custom settings which are passed when saving the form
     158     */
     159    public function sanitize_list( $input ) {
     160      foreach ( $input as $key => $option ) {
     161        if ($key === 'settings') {
     162          $valid_input[$key]['label_for'] = sanitize_text_field( $option['label_for'] );
     163          $valid_input[$key]['text'] = sanitize_text_field( $option['text'] );
     164        } else {
     165          $valid_input[$key]['label_for'] = sanitize_text_field( $option['label_for'] );
     166          $valid_input[$key]['url'] = sanitize_url( $option['url'] );
     167          $valid_input[$key]['active'] = ( isset($option['active']) ) ? true : false;
     168        }
     169      }
     170      return $valid_input;
    28171    }
    29   /**
    30   * @var array names of the share social medias and urls
    31   */
    32   public static $list = [
    33       ['name' => 'FaceBook', 'url' => 'https://www.facebook.com/sharer/sharer.php?u='],
    34       ['name' => 'Twitter', 'url' => 'https://twitter.com/share?url='],
    35       [
    36         'name' => 'Pinterest', 'url' => 'http://pinterest.com/pin/create/button/?url=',
    37         'imgurl' => '&amp;media=',
    38         'titleurl' => '&amp;description='
    39       ],
    40       ['name' => 'WhatsApp', 'url' => 'https://wa.me/?text='],
    41       ['name' => 'Telegram', 'url' => 'https://t.me/share/url?url='],
    42       ['name' => 'Email', 'url' => 'mailto:?body=']
    43       // CSS ready: insta,Map, Youtube, Twitch, linkedin, vimeo, github, WeChat, Tumblr, Viber, Snapchat, flipboard
    44   ];
    45   public static function removeExtraOptions() {
    46     delete_option(static::PAGE . '-gap-showtext' );
    47   }
    48   public static function getExtraSettings () {
    49     $text = __('Click to hide text before socials', static::LANGUAGE);
    50     register_setting(
    51       static::PAGE . static::EXTENSION,
    52       static::PAGE . '-gap-showtext'
    53     );
    54     add_settings_field(
    55       static::PAGE . static::EXTENSION . '_gap_showtext',
    56       $text,
    57       [static::class, 'showText'],
    58       static::PAGE . static::EXTENSION,
    59       static::PAGE . static::EXTENSION . '_section'
    60     );
    61   }
    62   public static function showText() {
    63       ?>
    64         <input
    65           type="checkbox"
    66           name="<?= static::PAGE . '-gap-showtext' ?>"
    67           class="checkbox show-text"
    68           title="<?php printf(__('Checkbox for hiding text', static::LANGUAGE)) ?>"
    69           <?php if (get_option(static::PAGE . '-gap-showtext')) {echo ' checked';} ?>
    70         >
    71       <?php
    72   }
    73172
    74   public static function registerSettingsText () {
    75     printf(
    76       __( 'Which social media do you want to share with your visitors', static::LANGUAGE ) .
    77       '<br>Shortcode = [' . static::PAGE . '-nav]'
    78     );
    79   }
    80   public static function addPageFunction($args) {
    81       ?>
    82         <input
    83           type="checkbox"
    84           class="checkbox"
    85           name="<?= static::PAGE . '-' . $args['class'] ?>"
    86           title="<?php printf(__('Checkbox for %1$s', static::LANGUAGE), $args['class']) ?>"
    87           <?php if (get_option(static::PAGE . '-' . $args['class'])) {echo ' checked';} ?>
    88         >
    89       <?php
    90   }
    91   public static function ShortcodeNav() {
    92       echo '<div class="' . static::PAGE . '">';
    93 
    94      if (!get_option(static::PAGE . '-agp-showtext')){
    95         echo '<div class="' . static::PAGE . '-text">';
    96           printf(__( 'Share this on', static::LANGUAGE ));
    97         echo '</div>';
    98       }
    99         foreach (static::$list as $social) {
    100               $class = strtolower($social['name']);
    101               if (isset($social['imgurl'])) {
    102                 $img = $social['imgurl'] . get_the_post_thumbnail_url(get_the_ID(),'full');
    103               } else { $img = '';}
    104               if (isset($social['titleurl'])) {
    105                 $title = $social['titleurl'] . get_the_title();
    106               } else { $title = '';}
    107 
    108               if (get_option(static::PAGE . '-' . $class)) {
    109                 echo '
    110                   <a
    111                     target="_blank"
    112                     title="' . __( 'Share this on', static::LANGUAGE ) . ' ' . $social['name'] . '"
    113                     href="' . $social['url'] . get_permalink() . $img . $title . '"
    114                   >
    115                     <div class="' . $class . '"></div>
    116                   </a>';
    117               }
    118         }
    119       echo '</div>';
    120   }
    121173}
  • socials-ga/trunk/includes/share-socials-admin.css

    r2456656 r2456670  
    1616}
    1717th {
    18     width: 60px !important;;
     18    width: 60px !important;
     19}
     20/* tr:first-of-type {width:calc(100% - 60px);} */
     21/* tr {width: calc(50% - 50px);} */
     22/* tr:first-of-type th {width:auto !important;} */
     23
     24table th {
     25    vertical-align: middle !important;
     26    padding-left: 15px !important;
     27}
     28tr:nth-child(1)::before{
     29    display: none;
     30}
     31tr:nth-child(1) th {
     32    width: 80px !important;
    1933}
    2034
    21 tr:first-of-type {width:calc(100% - 60px);}
    22 /* tr {width: calc(50% - 50px);} */
    23 tr:first-of-type th {width:auto !important;}
     35.follow-admin tr, .share-admin tr {
     36    width: calc(90% / 2 - 20px);
     37}
     38
     39tr:nth-child(1) {
     40    width: 90%;
     41}
     42tr td {
     43    float: inline-end;
     44    margin: 8px 0px;
     45}
     46tr th{
     47    float: inline-start;
     48}
     49@media screen and (max-width: 782px) {
     50
     51    .follow-admin tr, .share-admin tr {
     52    width:calc(90% / 2 - 15px);
     53    }
     54    tr:nth-child(1) {
     55        width: calc(90% + 10px);
     56    }
     57    tr::before {
     58        margin: 10px 0px;
     59    }
     60}
     61
     62@media screen and (max-width: 582px) {
     63    .follow-admin tr, .share-admin tr {
     64    width: 90%;
     65    }
     66    tr:nth-child(1) {
     67        width: 90%;
     68    }
     69    tr::before {
     70        margin: 10px 0px;
     71    }
     72}
     73@media screen and (min-width: 582px) {
     74 tr:nth-child(1) td, tr:nth-child(1) th {
     75     float:  inline-start;
     76    }
     77}
     78/* @media screen and (min-width: 782px) {
     79 tr:nth-child(1) td, tr:nth-child(1) th {
     80        margin: 10px;
     81    }
     82} */
     83tr::before {
     84    content: "=";
     85    vertical-align: middle;
     86    font-size: 2em;
     87    font-weight: bolder;
     88    color: white;
     89    /* margin: 5px 0px; */
     90    padding: 6px 10px 10px 10px;
     91    background-color: #777;
     92    border-radius: 3px;
     93}
     94
     95
     96.phone::before,
     97.email::before,
     98.map::before,
     99.youtube::before,
     100.vimeo::before,
     101.facebook::before,
     102.instagram::before,
     103.snapchat::before,
     104.twitter::before,
     105.whatsapp::before,
     106.telegram::before,
     107.viber::before,
     108.wechat::before,
     109.pinterest::before,
     110.linkedin::before,
     111.github::before,
     112.twitch::before,
     113.tumblr::before,
     114.flipboard::before,
     115.discord::before,
     116.flickr::before,
     117.deviantart::before,
     118.viadeo::before,
     119.skype::before {
     120
     121    content: "=";
     122}
     123
     124
     125.ui-sortable-handle td textarea:empty {
     126    width: 0;
     127    opacity: 0;
     128}
     129.ui-sortable-handle td {
     130    width: auto !important;
     131}
     132.ui-sortable-handle th {
     133    width: 100px !important;
     134}
     135.ui-sortable-handle td textarea:focus{
     136    width: calc(100%);
     137    opacity: 1;
     138}
     139.ui-sortable-handle {
     140    width: auto !important;
     141}
     142
     143
     144@media screen and (max-width:420px) {
     145    tr {
     146        width:80% !important;
     147    }
     148    .ui-sortable-handle td{
     149        float: inline-start;
     150    }
     151    .ui-sortable-handle {
     152        width: 80% !important;
     153    }
     154}
  • socials-ga/trunk/includes/share-socials.css

    r2456656 r2456670  
    33@import url('https://use.fontawesome.com/releases/v5.2.0/css/all.css');
    44
    5 .phone::before {
     5
     6th::before {
     7    vertical-align: middle;
     8    margin-right:5px;
     9    font-size: 2em;
     10}
     11.phone th::before, .phone::before {
    612    font-family: "dashicons";
    713    content: "\f525";
    814}
    9 .email::before {
     15.email th::before, .email::before {
    1016  font-family: "Font Awesome 5 Free";
    1117    content: "\f0e0";
     
    1319    content: "\f465";
    1420}
    15 .map::before {
     21.map th::before, .map::before {
    1622  font-family: "dashicons";
    1723  content: "\f109";
     
    1925    content: "\f279";
    2026}
    21 .youtube::before {
     27.youtube th::before, .youtube::before {
    2228  font-family: "Font Awesome 5 Brands";
    2329    content: "\f167";
    2430}
    25 .vimeo::before {
     31.vimeo th::before, .vimeo::before {
    2632  font-family: "Font Awesome 5 Brands";
    2733    content: "\f27d";
    2834}
    29 .facebook::before {
     35.facebook th::before, .facebook::before {
    3036  font-family: "Font Awesome 5 Brands";
    3137    content: "\f082";
     
    3339    content: "\f304";
    3440}
    35 .instagram::before{
     41.instagram th::before, .instagram::before {
    3642  font-family: "Font Awesome 5 Brands";
    3743    content: "\f16d";
    3844}
    39 .snapchat::before {
     45.snapchat th::before, .snapchat::before {
    4046  font-family: "Font Awesome 5 Brands";
    4147    content: "\f2ac";
    4248}
    43 .twitter::before {
     49.twitter th::before, .twitter::before {
    4450  font-family: "Font Awesome 5 Brands";
    4551    content: "\f099";
     
    4753    content: "\f301";
    4854}
    49 .whatsapp::before {
     55.whatsapp th::before, .whatsapp::before {
    5056  font-family: "Font Awesome 5 Brands";
    5157    content: "\f232";
    5258}
    53 .telegram::before {
     59.telegram th::before, .telegram::before {
    5460  font-family: "Font Awesome 5 Brands";
    5561    content: "\f3fe";
    5662}
    57 .viber::before {
     63.viber th::before, .viber::before {
    5864  font-family: "Font Awesome 5 Brands";
    5965    content: "\f409";
    6066}
    61 .wechat::before {
     67.wechat th::before, .wechat::before {
    6268  font-family: "Font Awesome 5 Brands";
    6369    content: "\f1d7";
    6470}
    65 .pinterest::before {
     71.pinterest th::before, .pinterest::before {
    6672  font-family: "Font Awesome 5 Brands";
    6773    content: "\f0d2";
    6874}
    69 .linkedin::before {
     75.linkedin th::before, .linkedin::before {
    7076  font-family: "Font Awesome 5 Brands";
    7177    content: "\f08c";
    7278}
    73 .github::before {
     79.github th::before, .github::before {
    7480  font-family: "Font Awesome 5 Brands";
    7581    content: "\f09b";
    7682}
    77 .twitch::before {
     83.twitch th::before, .twitch::before {
    7884  font-family: "Font Awesome 5 Brands";
    7985    content: "\f1e8";
    8086}
    81 .tumblr::before {
     87.tumblr th::before, .tumblr::before {
    8288  font-family: "Font Awesome 5 Brands";
    8389    content: "\f173";
    8490}
    85 .flipboard::before {
     91.flipboard th::before, .flipboard::before {
    8692  font-family: "Font Awesome 5 Brands";
    8793    content: "\f44d";
    8894}
    89 .discord::before {
     95.discord th::before, .discord::before {
    9096  font-family: "Font Awesome 5 Brands";
    9197    content: "\f392";
    9298}
    93 .flickr::before {
     99.flickr th::before, .flickr::before {
    94100  font-family: "Font Awesome 5 Brands";
    95101    content: "\f16e";
    96102}
    97 .deviantart::before {
     103.deviantart th::before, .deviantart::before {
    98104  font-family: "Font Awesome 5 Brands";
    99105    content: "\f1bd";
    100106}
    101 .viadeo::before {
     107.viadeo th::before, .viadeo::before {
    102108  font-family: "Font Awesome 5 Brands";
    103109    content: "\f2a9";
    104110}
    105 .skype::before {
     111.skype th::before, .skype::before {
    106112  font-family: "Font Awesome 5 Brands";
    107113    content: "\f17e";
     
    148154  float:left;
    149155  margin: 0px 5px;
     156    text-decoration: none;
    150157}
    151158.share :hover::before{
     
    158165/* FOLLOW */
    159166.follow {
    160 /*  color:white !important;
     167/*  color: white !important;
    161168    background-color: rgb(66, 103, 178, 0.4);
    162169  box-shadow: 0px 0px 7px rgba(255,255,255,0.3);
     
    190197  float:left;
    191198  margin: 0px 5px;
     199    text-decoration: none;
    192200}
    193201.follow :hover::before{
Note: See TracChangeset for help on using the changeset viewer.