Changeset 2469873
- Timestamp:
- 02/06/2021 12:25:10 AM (5 years ago)
- Location:
- socials-ga/trunk
- Files:
-
- 3 added
- 5 edited
-
README.md (modified) (2 diffs)
-
gaplugin-socials-plugin.php (modified) (1 diff)
-
gaplugin-socials.zip (added)
-
images (added)
-
images/icon.svg (added)
-
includes/AdminSocials.php (modified) (6 diffs)
-
includes/Follow.php (modified) (6 diffs)
-
includes/Share.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
socials-ga/trunk/README.md
r2456670 r2469873 1 1 # gaplugin-socials 2 === Socials - GA===2 === GAPlugins - Socials === 3 3 Author: Antoine GAUTIER 4 4 Author URI: gautierantoine.com … … 8 8 Tested up to: 5.5 9 9 Requires PHP: 7.2 10 Stable tag: 0.0 0.02.0210 Stable tag: 0.01.00.00 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
r2456670 r2469873 1 1 <?php 2 2 /** 3 * @package Socials-GA3 * @package GAP-Socials 4 4 */ 5 5 /* 6 Plugin Name: Socials-GA7 Plugin URI: https://github.com/ Pepite61/gaplugin-socials6 Plugin Name: GAP-Socials 7 Plugin URI: https://github.com/Gautier-Antoine/gaplugin-socials 8 8 Description: Plugin for your socials media 9 Version: 0.0 0.02.029 Version: 0.01.00.00 10 10 11 11 Requires at least: 5.2 -
socials-ga/trunk/includes/AdminSocials.php
r2456656 r2469873 1 1 <?php 2 2 /** 3 * @package Socials-GA3 * @package GAP-Socials 4 4 */ 5 5 namespace GAPlugin; … … 44 44 * @var string name for the admin page 45 45 */ 46 ADMINPAGE = 'ga -admin-page';46 ADMINPAGE = 'gap-admin-page'; 47 47 48 48 /** … … 71 71 */ 72 72 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'); 75 75 } 76 76 … … 81 81 public static function AdminScripts($suffix) { 82 82 if ($suffix === (strtolower(static::MENU) . '_page_' . static::ADMINPAGE . '-' . static::PAGE)) { 83 static::registerAdminScripts();84 }83 static::registerAdminScripts(); 84 } 85 85 } 86 86 … … 123 123 static::ADMINPAGE, 124 124 [static::class,'GAPlugin_admin_page'], 125 'dashicons-share', 125 static::getFolder() . 'images/icon.svg', 126 // 'dashicons-share', 126 127 30 127 128 ); … … 208 209 <input 209 210 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]' ?>" 212 213 class="textarea show-text" 213 214 title="<?php printf(__('Add some text before the links', static::LANGUAGE)) ?>" 214 value="<?= $args['text']?>"215 value="<?= esc_attr( $args['text'] ) ?>" 215 216 ></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> 217 218 <?php 218 219 } -
socials-ga/trunk/includes/Follow.php
r2456473 r2469873 1 1 <?php 2 2 /** 3 * @package Socials-GA3 * @package GAP-Socials 4 4 */ 5 5 namespace GAPlugin; … … 73 73 ?> 74 74 <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'] ) ?>" 77 77 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'] ) ) ?>" 79 79 ><?= 80 esc_ html( $args['url'] );80 esc_url( $args['url'] ); 81 81 ?></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> 83 83 <?php 84 84 } … … 89 89 public static function ShortcodeNav() { 90 90 $option_name = static::getOptionName(); 91 echo'<div class="' . static::PAGE . '">';91 $shortcode = '<div class="' . static::PAGE . '">'; 92 92 foreach ( get_option( $option_name ) as $id => $option ) { 93 93 if ( $id === 'settings' ) { 94 94 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>'; 98 98 } 99 99 } else { … … 106 106 } 107 107 if ( !empty ( $option['url'] ) ) { 108 echo'108 $shortcode .= ' 109 109 <a 110 110 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'] ) . '" 113 113 > 114 <div class="' . strtolower( $option['label_for']) . '"></div>114 <div class="' . strtolower( esc_attr( $option['label_for'] ) ) . '"></div> 115 115 </a> 116 116 '; … … 118 118 } 119 119 } 120 echo '</div>'; 120 $shortcode .= '</div>'; 121 return $shortcode; 121 122 } 122 123 … … 129 130 $options = (get_option( $option_name )) ?: static::$list; 130 131 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'] ) ); 133 134 add_settings_field( 134 135 $title, 135 $option['label_for'],136 esc_attr( $option['label_for'] ), 136 137 [static::class, 'addPageFunction'], 137 138 static::PAGE . static::EXTENSION, // Page 138 139 static::PAGE . static::EXTENSION . '_section', 139 140 [ 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'] ) ) 144 145 ] 145 146 ); 146 147 } else { 147 $title = static::PAGE . static::EXTENSION . '_' . strtolower( $option['label_for']);148 $title = static::PAGE . static::EXTENSION . '_' . strtolower( esc_attr( $option['label_for'] ) ); 148 149 add_settings_field( 149 150 $title, 150 $option['label_for'],151 esc_attr( $option['label_for'] ), 151 152 [static::class, 'showText'], 152 153 static::PAGE . static::EXTENSION, // Page 153 154 static::PAGE . static::EXTENSION . '_section', 154 155 [ 155 'label_for' => $option['label_for'],156 'text' => ( $option['text']) ?: null,157 'id' => $id156 'label_for' => esc_attr( $option['label_for'] ), 157 'text' => ( esc_attr( $option['text'] ) ) ?: null, 158 'id' => esc_attr( $id ) 158 159 ] 159 160 ); -
socials-ga/trunk/includes/Share.php
r2456670 r2469873 1 1 <?php 2 2 /** 3 * @package Socials-GA3 * @package GAP-Socials 4 4 */ 5 5 namespace GAPlugin; … … 56 56 public static function addPageFunction( $args ) { 57 57 $option_name = static::getOptionName(); 58 59 $checked = ( isset( $args['active'] ) && $args['active'] === '1' ) ? ' checked' : ''; 58 60 ?> 59 61 <input 60 62 type="checkbox" 61 63 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 ?> 66 68 > 67 69 </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> 69 71 </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> 71 77 72 78 <?php … … 78 84 public static function ShortcodeNav() { 79 85 $option_name = static::getOptionName(); 80 echo'<div class="' . static::PAGE . '">';86 $shortcode = '<div class="' . static::PAGE . '">'; 81 87 foreach ( get_option( $option_name ) as $id => $option ) { 82 88 if ( $id === 'settings' ) { 83 89 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>'; 87 93 } 88 94 } else { 89 if ($option['active'] === true) { 95 if ( $option['active'] === true ) { 96 // var_dump ($option); 97 90 98 $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' ); 93 101 } 94 102 $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(); 97 105 } 98 echo ' 106 $url = $option['url'] . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . $img . $title; 107 108 $shortcode .= ' 99 109 <a 100 110 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 ) . '" 103 113 > 104 <div class="' . strtolower( $option['label_for']) . '"></div>114 <div class="' . strtolower( esc_attr( $option['label_for'] ) ) . '"></div> 105 115 </a>'; 106 116 } 107 117 } 108 118 } 109 echo '</div>'; 119 $shortcode .= '</div>'; 120 return $shortcode; 110 121 } 111 122 … … 116 127 */ 117 128 public static function getFields( $option_name ) { 118 $options = ( get_option( $option_name )) ?: static::$list;129 $options = ( get_option( $option_name ) ) ?: static::$list; 119 130 foreach ( $options as $id => $option ) { 120 131 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'] ) ); 122 133 add_settings_field( 123 134 $title, 124 $option['label_for'],135 esc_attr( $option['label_for'] ), 125 136 [static::class, 'addPageFunction'], 126 137 static::PAGE . static::EXTENSION, // Page 127 138 static::PAGE . static::EXTENSION . '_section', 128 139 [ 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'] ) ) 134 147 ] 135 148 ); 136 149 } else { 137 $title = static::PAGE . static::EXTENSION . '_' . strtolower( $option['label_for']);150 $title = static::PAGE . static::EXTENSION . '_' . strtolower( esc_attr( $option['label_for'] ) ); 138 151 add_settings_field( 139 152 $title, 140 $option['label_for'],153 esc_attr( $option['label_for'] ), 141 154 [static::class, 'showText'], 142 155 static::PAGE . static::EXTENSION, // Page 143 156 static::PAGE . static::EXTENSION . '_section', 144 157 [ 145 'label_for' => $option['label_for'],146 'text' => ( $option['text']) ?: null,147 'id' => $id158 'label_for' => esc_attr( $option['label_for'] ), 159 'text' => ( $option['text'] ) ? esc_attr( $option['text'] ) : null, 160 'id' => esc_attr( $id ) 148 161 ] 149 162 ); … … 165 178 $valid_input[$key]['label_for'] = sanitize_text_field( $option['label_for'] ); 166 179 $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; 168 183 } 169 184 }
Note: See TracChangeset
for help on using the changeset viewer.