Changeset 2456670
- Timestamp:
- 01/15/2021 12:08:58 AM (5 years ago)
- Location:
- socials-ga/trunk
- Files:
-
- 5 edited
-
README.md (modified) (1 diff)
-
gaplugin-socials-plugin.php (modified) (1 diff)
-
includes/Share.php (modified) (2 diffs)
-
includes/share-socials-admin.css (modified) (1 diff)
-
includes/share-socials.css (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
socials-ga/trunk/README.md
r2456662 r2456670 8 8 Tested up to: 5.5 9 9 Requires PHP: 7.2 10 Stable tag: 0.00.02.0 110 Stable tag: 0.00.02.02 11 11 License: GPLv3 12 12 License URI: https://www.gnu.org/licenses/gpl-3.0.en.html -
socials-ga/trunk/gaplugin-socials-plugin.php
r2456662 r2456670 7 7 Plugin URI: https://github.com/Pepite61/gaplugin-socials 8 8 Description: Plugin for your socials media 9 Version: 0.00.02.0 19 Version: 0.00.02.02 10 10 11 11 Requires at least: 5.2 -
socials-ga/trunk/includes/Share.php
r2456656 r2456670 1 1 <?php 2 /** 3 * @package Socials-GA 4 */ 2 5 namespace GAPlugin; 3 6 /** … … 5 8 * manage the social media where we can share the article in your Share ShortcodeNav 6 9 */ 7 class Share extends AdminPage { 8 const 10 class 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 9 22 /** 10 * @var string name of the page23 * @var array names of the share social medias and urls 11 24 */ 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' => '&media=', 32 'titleurl' => '&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 13 41 /** 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() 15 55 */ 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 17 75 /** 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 21 112 /** 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 } 25 153 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; 28 171 } 29 /**30 * @var array names of the share social medias and urls31 */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' => '&media=',38 'titleurl' => '&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, flipboard44 ];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 <input65 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 <?php72 }73 172 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 <input83 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 <?php90 }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 <a111 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 }121 173 } -
socials-ga/trunk/includes/share-socials-admin.css
r2456656 r2456670 16 16 } 17 17 th { 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 24 table th { 25 vertical-align: middle !important; 26 padding-left: 15px !important; 27 } 28 tr:nth-child(1)::before{ 29 display: none; 30 } 31 tr:nth-child(1) th { 32 width: 80px !important; 19 33 } 20 34 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 39 tr:nth-child(1) { 40 width: 90%; 41 } 42 tr td { 43 float: inline-end; 44 margin: 8px 0px; 45 } 46 tr 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 } */ 83 tr::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 3 3 @import url('https://use.fontawesome.com/releases/v5.2.0/css/all.css'); 4 4 5 .phone::before { 5 6 th::before { 7 vertical-align: middle; 8 margin-right:5px; 9 font-size: 2em; 10 } 11 .phone th::before, .phone::before { 6 12 font-family: "dashicons"; 7 13 content: "\f525"; 8 14 } 9 .email ::before {15 .email th::before, .email::before { 10 16 font-family: "Font Awesome 5 Free"; 11 17 content: "\f0e0"; … … 13 19 content: "\f465"; 14 20 } 15 .map ::before {21 .map th::before, .map::before { 16 22 font-family: "dashicons"; 17 23 content: "\f109"; … … 19 25 content: "\f279"; 20 26 } 21 .youtube ::before {27 .youtube th::before, .youtube::before { 22 28 font-family: "Font Awesome 5 Brands"; 23 29 content: "\f167"; 24 30 } 25 .vimeo ::before {31 .vimeo th::before, .vimeo::before { 26 32 font-family: "Font Awesome 5 Brands"; 27 33 content: "\f27d"; 28 34 } 29 .facebook ::before {35 .facebook th::before, .facebook::before { 30 36 font-family: "Font Awesome 5 Brands"; 31 37 content: "\f082"; … … 33 39 content: "\f304"; 34 40 } 35 .instagram ::before{41 .instagram th::before, .instagram::before { 36 42 font-family: "Font Awesome 5 Brands"; 37 43 content: "\f16d"; 38 44 } 39 .snapchat ::before {45 .snapchat th::before, .snapchat::before { 40 46 font-family: "Font Awesome 5 Brands"; 41 47 content: "\f2ac"; 42 48 } 43 .twitter ::before {49 .twitter th::before, .twitter::before { 44 50 font-family: "Font Awesome 5 Brands"; 45 51 content: "\f099"; … … 47 53 content: "\f301"; 48 54 } 49 .whatsapp ::before {55 .whatsapp th::before, .whatsapp::before { 50 56 font-family: "Font Awesome 5 Brands"; 51 57 content: "\f232"; 52 58 } 53 .telegram ::before {59 .telegram th::before, .telegram::before { 54 60 font-family: "Font Awesome 5 Brands"; 55 61 content: "\f3fe"; 56 62 } 57 .viber ::before {63 .viber th::before, .viber::before { 58 64 font-family: "Font Awesome 5 Brands"; 59 65 content: "\f409"; 60 66 } 61 .wechat ::before {67 .wechat th::before, .wechat::before { 62 68 font-family: "Font Awesome 5 Brands"; 63 69 content: "\f1d7"; 64 70 } 65 .pinterest ::before {71 .pinterest th::before, .pinterest::before { 66 72 font-family: "Font Awesome 5 Brands"; 67 73 content: "\f0d2"; 68 74 } 69 .linkedin ::before {75 .linkedin th::before, .linkedin::before { 70 76 font-family: "Font Awesome 5 Brands"; 71 77 content: "\f08c"; 72 78 } 73 .github ::before {79 .github th::before, .github::before { 74 80 font-family: "Font Awesome 5 Brands"; 75 81 content: "\f09b"; 76 82 } 77 .twitch ::before {83 .twitch th::before, .twitch::before { 78 84 font-family: "Font Awesome 5 Brands"; 79 85 content: "\f1e8"; 80 86 } 81 .tumblr ::before {87 .tumblr th::before, .tumblr::before { 82 88 font-family: "Font Awesome 5 Brands"; 83 89 content: "\f173"; 84 90 } 85 .flipboard ::before {91 .flipboard th::before, .flipboard::before { 86 92 font-family: "Font Awesome 5 Brands"; 87 93 content: "\f44d"; 88 94 } 89 .discord ::before {95 .discord th::before, .discord::before { 90 96 font-family: "Font Awesome 5 Brands"; 91 97 content: "\f392"; 92 98 } 93 .flickr ::before {99 .flickr th::before, .flickr::before { 94 100 font-family: "Font Awesome 5 Brands"; 95 101 content: "\f16e"; 96 102 } 97 .deviantart ::before {103 .deviantart th::before, .deviantart::before { 98 104 font-family: "Font Awesome 5 Brands"; 99 105 content: "\f1bd"; 100 106 } 101 .viadeo ::before {107 .viadeo th::before, .viadeo::before { 102 108 font-family: "Font Awesome 5 Brands"; 103 109 content: "\f2a9"; 104 110 } 105 .skype ::before {111 .skype th::before, .skype::before { 106 112 font-family: "Font Awesome 5 Brands"; 107 113 content: "\f17e"; … … 148 154 float:left; 149 155 margin: 0px 5px; 156 text-decoration: none; 150 157 } 151 158 .share :hover::before{ … … 158 165 /* FOLLOW */ 159 166 .follow { 160 /* color: white !important;167 /* color: white !important; 161 168 background-color: rgb(66, 103, 178, 0.4); 162 169 box-shadow: 0px 0px 7px rgba(255,255,255,0.3); … … 190 197 float:left; 191 198 margin: 0px 5px; 199 text-decoration: none; 192 200 } 193 201 .follow :hover::before{
Note: See TracChangeset
for help on using the changeset viewer.