Changeset 3149972
- Timestamp:
- 09/11/2024 11:01:59 AM (18 months ago)
- Location:
- ybug-feedback-widget/trunk
- Files:
-
- 4 edited
-
admin/class-ybug-admin.php (modified) (3 diffs)
-
includes/class-ybug.php (modified) (1 diff)
-
public/class-ybug-public.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ybug-feedback-widget/trunk/admin/class-ybug-admin.php
r2821784 r3149972 116 116 } 117 117 118 /** 119 * Render Visibility field 120 * 121 * @since 1.2.0 122 */ 123 public function render_visibility_field( ) { 124 125 $options = get_option( 'ybug' ); 126 $options['visibility'] = @$options['visibility'] ?: 'frontend'; 127 ?> 128 <p> 129 <label> 130 <input name="ybug[visibility]" type="radio" value="frontend" class="tog" <?php checked( 'frontend' === $options['visibility'] ); ?> /> 131 <?php echo __( 'Show on the Website', 'ybug' ); ?> 132 </label> 133 </p> 134 <p> 135 <label> 136 <input name="ybug[visibility]" type="radio" value="admin" class="tog" <?php checked( 'admin' === $options['visibility'] ); ?> /> 137 <?php echo __( 'Show in the Admin Area', 'ybug' ); ?> 138 </label> 139 </p> 140 <p> 141 <label> 142 <input name="ybug[visibility]" type="radio" value="both" class="tog" <?php checked( 'both' === $options['visibility'] ); ?> /> 143 <?php echo __( 'Show on both (Website & Admin Area)', 'ybug' ); ?> 144 </label> 145 </p> 146 <?php 147 148 } 149 118 150 119 151 public function render_section_callback( ) { … … 222 254 ); 223 255 256 add_settings_field( 257 'visibility', 258 __( 'Where to show:', 'ybug' ), 259 array( $this, 'render_visibility_field' ), 260 'ybugSettings', 261 'Ybug_settings_section' 262 ); 263 224 264 225 265 wp_enqueue_style('admin_css', plugin_dir_url( __FILE__ ) . 'css/ybug-admin.css', array(), $this->version); … … 240 280 * @since 1.0.0 241 281 */ 242 public function enqueue_scripts() { 282 public function enqueue_scripts() 283 { 284 $this->enqueue_ybug_snippet(); 243 285 } 244 286 287 /** 288 * Render JS snippet for the admin area 289 * 290 * @since 1.2.0 291 */ 292 public function enqueue_ybug_snippet() 293 { 294 $options = get_option( 'ybug' ); 295 296 // Show to all logged in users 297 if (@$options['restrict_access'] === 'all' && !is_user_logged_in()) { 298 return; 299 } 300 301 // Show only to some users by role 302 if (@$options['restrict_access'] === 'roles') { 303 if (!array_filter($options['roles'], 'current_user_can')) { 304 return; 305 } 306 } 307 308 // Show only if admin visibility is enabled 309 if (!@$options['visibility'] || $options['visibility'] === 'frontend') { 310 return; 311 } 312 313 if (!@$options['project']) { 314 return; 315 } 316 317 $settings = [ 318 'id' => $options['project'], 319 ]; 320 321 // TODO ADD MORE SETTINGS 322 323 $snippet = " 324 <!-- Ybug code start (https://ybug.io) --> 325 <script type='text/javascript'> 326 (function() { 327 window.ybug_settings = " . json_encode($settings) . "; 328 var ybug = document.createElement('script'); ybug.type = 'text/javascript'; ybug.async = true; 329 ybug.src = 'https://widget.ybug.io/button/'+window.ybug_settings.id+'.js'; 330 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ybug, s); 331 })(); 332 </script> 333 <!-- Ybug code end -->"; 334 335 wp_register_script('ybug-admin-snippet', ''); 336 wp_enqueue_script('ybug-admin-snippet'); 337 wp_add_inline_script('ybug-admin-snippet', $snippet); 338 } 339 245 340 } -
ybug-feedback-widget/trunk/includes/class-ybug.php
r2821784 r3149972 137 137 add_action( 'admin_init', array( $plugin_admin, 'admin_init' ) ); 138 138 139 // $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); 140 // $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); 141 139 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); 140 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); 142 141 } 143 142 -
ybug-feedback-widget/trunk/public/class-ybug-public.php
r2821784 r3149972 52 52 } 53 53 54 // Show only if frontend visibility is enabled (default) 55 if (@$options['visibility'] && ($options['visibility'] === 'admin')) { 56 return; 57 } 58 54 59 if (@$options['project']) { 55 60 -
ybug-feedback-widget/trunk/readme.txt
r2821786 r3149972 3 3 Tags: feedback, bug-tracking, user feedback, visual feedback, feedback widget, feedback button, screenshot 4 4 Requires at least: 3.0.1 5 Tested up to: 6. 16 Stable tag: 1. 1.15 Tested up to: 6.6 6 Stable tag: 1.2.0 7 7 Requires PHP: 5.3 8 8 License: GPLv2 or later … … 62 62 * Added new setting - access restriction 63 63 64 = 1.2.0 = 65 * Added new setting - widget visibility (website vs admin area) 66 64 67 == Upgrade Notice ==
Note: See TracChangeset
for help on using the changeset viewer.