Changeset 3316572
- Timestamp:
- 06/23/2025 10:54:19 PM (6 months ago)
- Location:
- adminsanity/trunk
- Files:
-
- 5 edited
-
adminsanity.php (modified) (2 diffs)
-
adminsanity/adminsanity-bar.php (modified) (2 diffs)
-
loader.php (modified) (70 diffs)
-
readme.md (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
adminsanity/trunk/adminsanity.php
r3115930 r3316572 5 5 Plugin URI: https://wpmedic.tech/adminsanity/ 6 6 Description: Add Sanity back to your WordPress Admin Area. 7 Version: 1.0. 37 Version: 1.0.4 8 8 Author: Tony Hayes 9 9 Author URI: https://wpmedic.tech … … 91 91 92 92 // --- bar frontend --- 93 'bar_cycler' => array( 93 // 1.0.4: fix to bar frontend settings key 94 'bar_frontend' => array( 94 95 'type' => 'checkbox', 95 96 'default' => 'yes', -
adminsanity/trunk/adminsanity/adminsanity-bar.php
r3115930 r3316572 531 531 // ----------------- 532 532 // 0.9.9: emqueue scripts with wp_after_admin_bar_render hook 533 add_action( 'wp_after_admin_bar_render', 'adminsanity_bar_enqueue_scripts' ); 534 function adminsanity_bar_enqueue_scripts() { 535 add_action( 'admin_footer', 'adminsanity_bar_scripts' ); 536 add_action( 'wp_footer', 'adminsanity_bar_scripts' ); 537 } 533 // add_action( 'wp_after_admin_bar_render', 'adminsanity_bar_enqueue_scripts' ); 534 // function adminsanity_bar_enqueue_scripts() { 535 // add_action( 'admin_footer', 'adminsanity_bar_scripts' ); 536 // add_action( 'wp_footer', 'adminsanity_bar_scripts' ); 537 // } 538 // 1.0.4: do not enqueue as too late for frontend 539 add_action( 'wp_after_admin_bar_render', 'adminsanity_bar_scripts' ); 538 540 function adminsanity_bar_scripts() { 539 541 … … 636 638 }); 637 639 }" . "\n"; 638 639 if ( !$cycler && !$dropdown ) {640 return;641 }642 640 643 641 // --- bar cycler script --- -
adminsanity/trunk/loader.php
r3115930 r3316572 5 5 // ================================= 6 6 7 // ------------- 8 // Loader v1.3.5 9 // ------------- 10 // Note: Changelog at end of file. 11 7 12 if ( !defined( 'ABSPATH' ) ) exit; 8 13 9 // -------------- 10 // Version: 1.3.0 11 // -------------- 12 // Note: Changelog and structure at end of file. 13 // 14 // === Loader Class === 15 // - Initialize Loader 16 // - Setup Plugin 17 // - Get Plugin Data 18 // - Get Plugin Version 19 // - Set Pro Namespace 20 // === Plugin Settings === 21 // - Get Default Settings 22 // - Add Settings 23 // - Maybe Transfer Settings 24 // - Get All Plugin Settings 25 // - Get Plugin Setting 26 // - Reset Plugin Settings 27 // - Update Plugin Settings 28 // - Validate Plugin Setting 29 // === Plugin Loading === 30 // - Load Plugin Settings 31 // - Add Actions 32 // - Load Helper Libraries 33 // - Maybe Load Thickbox 34 // - Readme Viewer AJAX 35 // === Freemius Loading === 36 // - Load Freemius 37 // - Filter Freemius Connect 38 // - Freemius Connect Message 39 // - Connect Update Message 40 // === Plugin Admin === 41 // - Add Settings Menu 42 // - Plugin Page Links 43 // - Message Box 44 // - Notice Boxer 45 // - Plugin Page Header 46 // - Settings Page 47 // - Settings Table 48 // - Setting Row 49 // - Settings Scripts 50 // - Settings Styles 51 // === Namespaced Functions === 52 53 14 54 // ============ 15 55 // Loader Usage 16 56 // ============ 17 57 // 1. replace all occurrences of adminsanity_ in this file with the plugin namespace prefix eg. my_plugin_ 58 // 2. replace all occurrences of 'radio-station' in this file with the plugin's translation text domain 18 59 // 2. define plugin options, default settings, and setup arguments your main plugin file 19 60 // 3. require this file in the main plugin file and instantiate the loader class (see example below) … … 59 100 // 'home' => 'http://mysite.com/plugins/plugin/', 60 101 // 'support' => 'http://mysite.com/plugins/plugin/support/', 61 // 'ratetext' => __( 'Rate on WordPress.org'), // (overrides default rate text)102 // 'ratetext' => __( 'Rate on WordPress.org', 'radio-station' ), // (overrides default rate text) 62 103 // 'share' => 'http://mysites.com/plugins/plugin/#share', // (set sharing URL) 63 // 'sharetext' => __( 'Share the Plugin Love'), // (overrides default sharing text)104 // 'sharetext' => __( 'Share the Plugin Love', 'radio-station' ), // (overrides default sharing text) 64 105 // 'donate' => 'https://patreon.com/pagename', // (overrides plugin Donate URI) 65 // 'donatetext' => __( 'Support this Plugin'), // (overrides default donate text)106 // 'donatetext' => __( 'Support this Plugin', 'radio-station' ), // (overrides default donate text) 66 107 // 'readme' => false, // to not link to popup readme in settings page header 67 108 // 'settingsmenu' => false, // to not automatically add a settings menu [non-WQ] … … 76 117 // 'wporgslug' => 'plugin-slug', // WordPress.org plugin slug 77 118 // 'wporg' => false, // * rechecked later (via presence of updatechecker.php) * 78 // 'textdomain' => ' text-domain', // translation text domain (usually same as plugin slug)119 // 'textdomain' => 'radio-station', // translation text domain (usually same as plugin slug) 79 120 // 80 121 // // --- Freemius --- … … 439 480 // 1.0.5: use sanitize_title on request variables 440 481 // phpcs:ignore WordPress.Security.NonceVerification.Recommended 441 if ( sanitize_text_field( $_REQUEST['page']) != $args['slug'] ) {482 if ( sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ) != $args['slug'] ) { 442 483 return; 443 484 } … … 446 487 } 447 488 // phpcs:ignore WordPress.Security.NonceVerification.Missing 448 if ( 'reset' != sanitize_text_field( $_POST[$args['namespace'] . '_update_settings']) ) {489 if ( 'reset' != sanitize_text_field( wp_unslash( $_POST[$args['namespace'] . '_update_settings'] ) ) ) { 449 490 return; 450 491 } … … 487 528 // 1.0.3: only use namespace not settings key 488 529 // 1.0.9: check page is set and matches slug 489 if ( !isset( $_REQUEST['page'] ) || ( sanitize_text_field( $_REQUEST['page']!= $args['slug'] ) ) ) {530 if ( !isset( $_REQUEST['page'] ) || ( sanitize_text_field( wp_unslash( $_REQUEST['page'] ) != $args['slug'] ) ) ) { 490 531 return; 491 532 } 492 533 $updatekey = $args['namespace'] . '_update_settings'; 493 534 // phpcs:ignore WordPress.Security.NonceVerification.Missing 494 if ( !isset( $_POST[$updatekey] ) || ( 'yes' != sanitize_text_field( $_POST[$args['namespace'] . '_update_settings']) ) ) {535 if ( !isset( $_POST[$updatekey] ) || ( 'yes' != sanitize_text_field( wp_unslash( $_POST[$updatekey] ) ) ) ) { 495 536 return; 496 537 } … … 505 546 // $noncecheck = wp_verify_nonce( sanitize_text_field( $_POST['_wpnonce'] ), $args['slug'] . '_update_settings' ); 506 547 check_admin_referer( $args['slug'] . '_update_settings' ); 548 549 // --- debug posted values --- 550 // 1.3.?: move debug output to after check_admin_referer 551 $this->debug_posted( $settings ); 507 552 508 553 // --- get plugin options and default settings --- … … 598 643 599 644 // --- implicit radio / select --- 600 $posted = isset( $_POST[$postkey] ) ? sanitize_text_field( $_POST[$postkey]) : null;645 $posted = isset( $_POST[$postkey] ) ? sanitize_text_field( wp_unslash( $_POST[$postkey] ) ) : null; 601 646 $valid = explode( '/', $type ); 602 647 if ( in_array( $posted, $valid ) ) { … … 609 654 // 1.0.6: fix to new unchecked checkbox value 610 655 // 1.0.9: maybe validate to specified checkbox value 611 $posted = isset( $_POST[$postkey] ) ? sanitize_text_field( $_POST[$postkey]) : null;656 $posted = isset( $_POST[$postkey] ) ? sanitize_text_field( wp_unslash( $_POST[$postkey] ) ) : null; 612 657 if ( isset( $values['value'] ) ) { 613 658 $valid = array( $values['value'] ); … … 625 670 // --- text area --- 626 671 // 1.2.5: use sanitize_textarea_field with stripslashes 627 $posted = isset( $_POST[$postkey] ) ? sanitize_textarea_field( $_POST[$postkey]) : null;672 $posted = isset( $_POST[$postkey] ) ? sanitize_textarea_field( wp_unslash( $_POST[$postkey] ) ) : null; 628 673 // 1.3.0: move use of stripslashes to separate line 629 674 if ( !is_null( $posted ) ) { … … 636 681 // --- text field (slug) --- 637 682 // 1.0.9: move text field sanitization to validation 638 $posted = isset( $_POST[$postkey] ) ? sanitize_text_field( $_POST[$postkey]) : null;683 $posted = isset( $_POST[$postkey] ) ? sanitize_text_field( wp_unslash( $_POST[$postkey] ) ) : null; 639 684 if ( !is_string( $valid ) ) { 640 685 $valid = 'TEXT'; … … 646 691 // --- email field --- 647 692 // 1.3.0: added explicitly for email field type 648 $posted = isset( $_POST[$postkey] ) ? sanitize_text_field( $_POST[$postkey]) : null;693 $posted = isset( $_POST[$postkey] ) ? sanitize_text_field( wp_unslash( $_POST[$postkey] ) ) : null; 649 694 if ( !is_string( $valid ) ) { 650 695 $valid = 'EMAIL'; … … 656 701 // --- number field value --- 657 702 // 1.0.9: added support for number step, minimum and maximum 658 $posted = isset( $_POST[$postkey] ) ? sanitize_text_field( $_POST[$postkey]) : null;703 $posted = isset( $_POST[$postkey] ) ? sanitize_text_field( wp_unslash( $_POST[$postkey] ) ) : null; 659 704 $newsettings = $posted; 660 705 $valid = 'NUMERIC'; … … 680 725 // 1.1.2: check for value if specified 681 726 // 1.2.5: apply sanitize_text_field to posted value 682 if ( ( isset( $values['value'] ) && ( sanitize_text_field( $_POST[$optionkey]) == $values['value'] ) )683 || ( !isset( $values['value'] ) && ( 'yes' == sanitize_text_field( $_POST[$optionkey]) ) ) ) {727 if ( ( isset( $values['value'] ) && ( sanitize_text_field( wp_unslash( $_POST[$optionkey] ) ) == $values['value'] ) ) 728 || ( !isset( $values['value'] ) && ( 'yes' == sanitize_text_field( wp_unslash( $_POST[$optionkey] ) ) ) ) ) { 684 729 // 1.1.0: fixed to save only array of key values 685 730 $posted[] = $option; … … 693 738 // -- comma separated values --- 694 739 // 1.0.4: added comma separated values option 695 $posted = isset( $_POST[$postkey] ) ? sanitize_text_field( $_POST[$postkey]) : null;740 $posted = isset( $_POST[$postkey] ) ? sanitize_text_field( wp_unslash( $_POST[$postkey] ) ) : null; 696 741 if ( strstr( $posted, ',' ) ) { 697 742 $posted = explode( ',', $posted ); … … 720 765 721 766 // --- explicit radio or select value --- 722 $posted = isset( $_POST[$postkey] ) ? sanitize_text_field( $_POST[$postkey]) : null;767 $posted = isset( $_POST[$postkey] ) ? sanitize_text_field( wp_unslash( $_POST[$postkey] ) ) : null; 723 768 if ( is_string( $valid ) ) { 724 769 $newsettings = $posted; … … 731 776 // --- multiselect values --- 732 777 // 1.0.9: added multiselect value saving 733 $posted = isset( $_POST[$postkey] ) ? array_map( 'sanitize_text_field', $_POST[$postkey]) : array();778 $posted = isset( $_POST[$postkey] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST[$postkey] ) ) : array(); 734 779 $newsettings = array_values( $posted ); 735 780 … … 738 783 // --- check attachment ID value --- 739 784 // 1.1.7: add image attachment ID saving 740 $posted = isset( $_POST[$postkey] ) ? absint( $_POST[$postkey]) : null;785 $posted = isset( $_POST[$postkey] ) ? absint( wp_unslash( $_POST[$postkey] ) ) : null; 741 786 if ( $posted ) { 742 787 $attachment = wp_get_attachment_image_src( $posted, 'full' ); … … 751 796 // 1.1.7: added color picker value saving 752 797 // 1.2.5: use sanitize_hex_color on color field 753 $posted = isset( $_POST[$postkey] ) ? sanitize_hex_color( $_POST[$postkey]) : null;798 $posted = isset( $_POST[$postkey] ) ? sanitize_hex_color( wp_unslash( $_POST[$postkey] ) ) : null; 754 799 $settings[$key] = $posted; 755 800 … … 760 805 // 1.2.5: added rgba version of sanitization 761 806 // ref: https://wordpress.stackexchange.com/a/262578/76440 762 $posted = isset( $_POST[$postkey] ) ? sanitize_text_field( $_POST[$postkey]) : null;807 $posted = isset( $_POST[$postkey] ) ? sanitize_text_field( wp_unslash( $_POST[$postkey] ) ) : null; 763 808 if ( !is_null( $posted ) ) { 764 809 $posted = str_replace( ' ', '', $posted ); … … 807 852 // --- fallback to text type --- 808 853 // 1.3.0: added for unspecified option field type 809 $posted = isset( $_POST[$postkey] ) ? sanitize_text_field( $_POST[$postkey]) : null;854 $posted = isset( $_POST[$postkey] ) ? sanitize_text_field( wp_unslash( $_POST[$postkey] ) ) : null; 810 855 if ( !is_string( $valid ) ) { 811 856 $valid = 'TEXT'; … … 943 988 if ( count( $tabs ) > 0 ) { 944 989 // 1.2.5: sanitize current tab value before validating 945 $currenttab = sanitize_text_field( $_POST['settingstab']);990 $currenttab = sanitize_text_field( wp_unslash( $_POST['settingstab'] ) ); 946 991 if ( in_array( $currenttab, $tabs ) ) { 947 992 $settings['settingstab'] = $currenttab; … … 986 1031 } 987 1032 1033 // -------------------------- 1034 // Debug Output Posted Values 1035 // -------------------------- 1036 function debug_posted( $settings ) { 1037 if ( $this->debug ) { 1038 echo '<br><b>Current Settings:</b><br>'; 1039 // phpcs:ignore WordPress.PHP.DevelopmentFunctions 1040 echo esc_html( print_r( $settings, true ) ); 1041 echo '<br><br>' . "\n"; 1042 1043 echo '<br><b>Plugin Options:</b><br>'; 1044 // phpcs:ignore WordPress.PHP.DevelopmentFunctions 1045 echo esc_html( print_r( $this->options, true ) ); 1046 echo '<br><br>' . "\n"; 1047 1048 // phpcs:ignore WordPress.Security.NonceVerification.Missing 1049 if ( isset( $_POST ) ) { 1050 echo '<br><b>Posted Values:</b><br>'; 1051 // phpcs:ignore WordPress.Security.NonceVerification.Missing 1052 $post_keys = array_keys( $_POST ); 1053 foreach ( $post_keys as $post_key ) { 1054 $post_key = sanitize_text_field( $post_key ); 1055 $value = sanitize_text_field( $_POST[$post_key] ); 1056 // phpcs:ignore WordPress.PHP.DevelopmentFunctions 1057 echo esc_html( $post_key ) . ': ' . esc_html( print_r( $value, true ) ) . '<br>' . "\n"; 1058 } 1059 } 1060 } 1061 } 1062 988 1063 // ----------------------- 989 1064 // Validate Plugin Setting … … 1265 1340 register_deactivation_hook( $args['file'], array( $this, 'delete_settings' ) ); 1266 1341 1267 // --- maybe loadthickbox ---1342 // --- maybe enqueue scripts / thickbox --- 1268 1343 add_action( 'admin_enqueue_scripts', array( $this, 'maybe_load_thickbox' ) ); 1344 // 1.3.4: add earlier enqueue settings page resources check 1345 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_resources' ) ); 1269 1346 1270 1347 // --- AJAX readme viewer --- … … 1348 1425 $args = $this->args; 1349 1426 // phpcs:ignore WordPress.Security.NonceVerification.Recommended 1350 if ( isset( $_REQUEST['page'] ) && ( sanitize_t itle( $_REQUEST['page']) == $args['slug'] ) ) {1427 if ( isset( $_REQUEST['page'] ) && ( sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ) == $args['slug'] ) ) { 1351 1428 add_thickbox(); 1352 1429 } … … 1365 1442 // 1.0.7: changed readme.php to reader.php (for Github) 1366 1443 $readme = $dir . '/readme.txt'; 1444 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents 1367 1445 $contents = file_get_contents( $readme ); 1368 1446 $parser = $dir . '/reader.php'; … … 1373 1451 include $parser; 1374 1452 1375 // --- remove license info as causes breakage! --- 1376 // TODO: find line start and end to handle other possible licenses 1377 $contents = str_replace( 'License: GPLv2 or later', '', $contents ); 1378 $contents = str_replace( 'License URI: http://www.gnu.org/licenses/gpl-2.0.html', '', $contents ); 1453 // --- remove license lines as causing breakage! --- 1454 // 1.3.1: find license lines to handle other possible licenses 1455 // $contents = str_replace( 'License: GPLv2 or later', '', $contents ); 1456 // $contents = str_replace( 'License URI: http://www.gnu.org/licenses/gpl-2.0.html', '', $contents ); 1457 $strip_lines = array( 'License', 'License URI' ); 1458 foreach( $strip_lines as $strip_line ) { 1459 if ( strstr( $contents, $strip_line ) ) { 1460 $pos = strpos( $contents, $strip_line . ':' ); 1461 $chunks = str_split( $contents, $pos ); 1462 $before = $chunks[0]; 1463 unset( $chunks[0] ); 1464 $remainder = implode( '', $chunks ); 1465 $posb = strpos( $remainder, "\n" ); 1466 $chunks = str_split( $remainder, $posb ); 1467 unset( $chunks[0] ); 1468 $remainder = implode( '', $chunks ); 1469 $contents = $before . $remainder; 1470 } 1471 } 1379 1472 1380 1473 // --- instantiate Parser class --- 1381 $readme = new WordPress_Readme_Parser(); 1474 // 1.3.1: prefix readme parser 1475 $readme = new adminsanity_readme_parser(); 1382 1476 $parsed = $readme->parse_readme_contents( $contents ); 1383 1477 1384 1478 // --- output plugin info --- 1385 echo '<b>' . esc_html( __( 'Plugin Name' ) ) . '</b>: ' . esc_html( $parsed['name'] ) . '<br>' . "\n";1386 // echo '<b>' . esc_html( __( 'Tags' ) ) . '</b>: ' . esc_html( implode( ', ', $parsed['tags'] ) ) . '<br>' . "\n";1387 echo '<b>' . esc_html( __( 'Requires at least' ) ) . '</b>: ' . esc_html( __( 'WordPress' ) ) . ' v' . esc_html( $parsed['requires_at_least'] ) . '<br>' . "\n";1388 echo '<b>' . esc_html( __( 'Tested up to' ) ) . '</b>: ' . esc_html( __( 'WordPress' ) ) . ' v' . esc_html( $parsed['tested_up_to'] ) . '<br>' . "\n";1479 echo '<b>' . esc_html( __( 'Plugin Name', 'radio-station' ) ) . '</b>: ' . esc_html( $parsed['name'] ) . '<br>' . "\n"; 1480 // echo '<b>' . esc_html( __( 'Tags', 'radio-station' ) ) . '</b>: ' . esc_html( implode( ', ', $parsed['tags'] ) ) . '<br>' . "\n"; 1481 echo '<b>' . esc_html( __( 'Requires at least', 'radio-station' ) ) . '</b>: ' . esc_html( __( 'WordPress', 'radio-station' ) ) . ' v' . esc_html( $parsed['requires_at_least'] ) . '<br>' . "\n"; 1482 echo '<b>' . esc_html( __( 'Tested up to', 'radio-station' ) ) . '</b>: ' . esc_html( __( 'WordPress', 'radio-station' ) ) . ' v' . esc_html( $parsed['tested_up_to'] ) . '<br>' . "\n"; 1389 1483 if ( isset( $parsed['stable_tag'] ) ) { 1390 echo '<b>' . esc_html( __( 'Stable Tag' ) ) . '</b>: ' . esc_html( $parsed['stable_tag'] ) . '<br>' . "\n";1391 } 1392 echo '<b>' . esc_html( __( 'Contributors' ) ) . '</b>: ' . esc_html( implode( ', ', $parsed['contributors'] ) ) . '<br>' . "\n";1484 echo '<b>' . esc_html( __( 'Stable Tag', 'radio-station' ) ) . '</b>: ' . esc_html( $parsed['stable_tag'] ) . '<br>' . "\n"; 1485 } 1486 echo '<b>' . esc_html( __( 'Contributors', 'radio-station' ) ) . '</b>: ' . esc_html( implode( ', ', $parsed['contributors'] ) ) . '<br>' . "\n"; 1393 1487 // echo '<b>Donate Link</b>: <a href="' . esc_url( $parsed['donate_link'] ) . '" target="_blank">' . esc_html( $parsed['donate_link'] ) . '</a><br>'; 1394 1488 // 1.2.5: use wp_kses_post on plugin short description markup … … 1416 1510 } 1417 1511 if ( isset( $parsed['remaining_content'] ) && !empty( $remaining_content ) ) { 1418 echo '<h3>' . esc_html( __( 'Extra Notes' ) ) . '</h3>' . "\n";1512 echo '<h3>' . esc_html( __( 'Extra Notes', 'radio-station' ) ) . '</h3>' . "\n"; 1419 1513 // 1.2.5: use wp_kses_post on readme extra notes output 1420 1514 echo wp_kses_post( $parsed['remaining_content'] ); … … 1485 1579 // 1.0.5: use sanitize_text_field on request variable 1486 1580 // phpcs:ignore WordPress.Security.NonceVerification.Recommended 1487 if ( isset( $_REQUEST['page'] ) && ( sanitize_title( $_REQUEST['page'] ) == $args['slug'] . '-wp-support-forum' ) && is_admin() ) { 1488 if ( !function_exists( 'wp_redirect' ) ) { 1489 include ABSPATH . WPINC . '/pluggable.php'; 1490 } 1581 if ( isset( $_REQUEST['page'] ) && ( sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ) == $args['slug'] . '-wp-support-forum' ) && is_admin() ) { 1582 // 1.0.7: fix support URL undefined variable warning 1491 1583 if ( isset( $args['support'] ) ) { 1492 // changes the support forum slug for premium based on the pro plugin file slug 1493 // 1.0.7: fix support URL undefined variable warning 1494 $support_url = $args['support']; 1495 // 1.2.1: removed in favour of filtering via Pro 1496 // if ( $premium && isset( $args['proslug'] ) ) { 1497 // $support_url = str_replace( $args['slug'], $args['proslug'], $support_url ); 1498 // } 1499 $support_url = apply_filters( 'freemius_plugin_support_url_redirect', $support_url, $args['slug'] ); 1500 // phpcs:ignore WordPress.Security.SafeRedirect 1501 wp_redirect( $support_url ); 1502 exit; 1584 // 1.3.6: add action and bug out on redirect 1585 add_action( 'admin_init', array( $this, 'support_redirect' ) ); 1586 return; 1503 1587 } 1504 1588 } … … 1510 1594 if ( !class_exists( 'Freemius' ) ) { 1511 1595 $freemiuspath = dirname( __FILE__ ) . '/freemius/start.php'; 1596 $freemiuspath = apply_filters( 'freemius_load_path', $freemiuspath, $namespace, $args ); 1512 1597 if ( !file_exists( $freemiuspath ) ) { 1513 1598 return; … … 1546 1631 } 1547 1632 if ( !isset( $args['affiliation'] ) ) { 1548 $args['affiliaation'] = false; 1633 // 1.3.1: fix to key typo (affiliaation) 1634 $args['affiliation'] = false; 1549 1635 } 1550 1636 … … 1624 1710 } 1625 1711 1712 // ---------------- 1713 // Support Redirect 1714 // ---------------- 1715 // 1.3.6: enqueued on admin_init for slightly later execution 1716 function support_redirect() { 1717 1718 $args = $this->args; 1719 $support_url = $args['support']; 1720 1721 // changes the support forum slug for premium based on the pro plugin file slug 1722 // 1.2.1: removed in favour of filtering via Pro 1723 // if ( $premium && isset( $args['proslug'] ) ) { 1724 // $support_url = str_replace( $args['slug'], $args['proslug'], $support_url ); 1725 // } 1726 $support_url = apply_filters( 'freemius_plugin_support_url_redirect', $support_url, $args['slug'] ); 1727 1728 // 1.3.6: removed conditional include of pluggable (no longer necessary) 1729 // phpcs:ignore WordPress.Security.SafeRedirect 1730 wp_redirect( $support_url ); 1731 exit; 1732 } 1733 1626 1734 // ------------------------ 1627 1735 // Freemius Connect Message … … 1634 1742 $message .= sprintf( 1635 1743 // Translators: plugin title, user name, site link, freemius link 1636 __( 'If you want to more easily access support and feedback for this plugins features and functionality, %1$s can connect your user, %2$s at %3$s, to %4$s' ),1744 __( 'If you want to more easily access support and feedback for this plugins features and functionality, %1$s can connect your user, %2$s at %3$s, to %4$s', 'radio-station' ), 1637 1745 '<b>' . $plugin_title . '</b>', 1638 1746 '<b>' . $user_login . '</b>', … … 1660 1768 // ==================== 1661 1769 1770 // -------------------------------- 1771 // Enequeue Settings Page Resources 1772 // -------------------------------- 1773 // 1.3.4: added enqueue resources function 1774 public function enqueue_resources() { 1775 1776 $args = $this->args; 1777 $namespace = $this->namespace; 1778 1779 if ( isset( $_REQUEST['page'] ) && ( sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ) == $args['slug'] ) ) { 1780 1781 // --- get plugin options and default settings --- 1782 // 1.1.2: fix for filtering of plugin options 1783 $options = $this->options; 1784 $options = apply_filters( $namespace . '_options', $options ); 1785 1786 // --- maybe enqueue media scripts --- 1787 // 1.1.7: added media gallery script enqueueing for image field 1788 // 1.1.7: added color picker and color picker alpha script enqueueing 1789 $enqueued_media = $enqueued_color_picker = $enqueue_color_picker = $enqueue_color_picker_alpha = false; 1790 foreach ( $options as $option ) { 1791 if ( ( 'image' == $option['type'] ) && !$enqueued_media ) { 1792 wp_enqueue_media(); 1793 $enqueued_media = true; 1794 } elseif ( 'color' == $option['type'] ) { 1795 $enqueue_color_picker = true; 1796 } elseif ( 'coloralpha' == $option['type'] ) { 1797 $enqueue_color_picker_alpha = true; 1798 } 1799 } 1800 1801 // 1.2.5: moved out of 1802 if ( $enqueue_color_picker_alpha ) { 1803 wp_enqueue_style( 'wp-color-picker' ); 1804 $suffix = '.min'; 1805 if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { 1806 $suffix = ''; 1807 } 1808 $url = plugins_url( '/js/wp-color-picker-alpha' . $suffix . '.js', $args['file'] ); 1809 wp_enqueue_script( 'wp-color-picker-a', $url, array( 'wp-color-picker' ), '3.0.0', true ); 1810 $enqueued_color_picker = true; 1811 } elseif ( $enqueue_color_picker ) { 1812 wp_enqueue_style( 'wp-color-picker' ); 1813 wp_enqueue_script( 'wp-color-picker' ); 1814 $enqueued_color_picker = true; 1815 } 1816 1817 // --- enqueue print of settings scripts / styles --- 1818 $this->settings_resources( $enqueued_media, $enqueued_color_picker ); 1819 } 1820 } 1821 1662 1822 // ----------------- 1663 1823 // Add Settings Menu … … 1718 1878 $page = $this->menu_added ? 'admin.php' : 'options-general.php'; 1719 1879 $settings_url = add_query_arg( 'page', $args['slug'], admin_url( $page ) ); 1720 $settings_link = '<a href="' . esc_url( $settings_url ) . '">' . esc_html( __( 'Settings' ) ) . '</a>';1880 $settings_link = '<a href="' . esc_url( $settings_url ) . '">' . esc_html( __( 'Settings', 'radio-station' ) ) . '</a>'; 1721 1881 $link = array( 'settings' => $settings_link ); 1722 1882 $links = array_merge( $link, $links ); … … 1736 1896 $upgrade_target = !strstr( $upgrade_url, '/wp-admin/' ) ? ' target="_blank"' : ''; 1737 1897 } 1738 $upgrade_link = '<b><a href="' . esc_url( $upgrade_url ) . '"' . $upgrade_target . ">" . esc_html( __( 'Upgrade' ) ) . '</a></b>';1898 $upgrade_link = '<b><a href="' . esc_url( $upgrade_url ) . '"' . $upgrade_target . ">" . esc_html( __( 'Upgrade', 'radio-station' ) ) . '</a></b>'; 1739 1899 $link = array( 'upgrade' => $upgrade_link ); 1740 1900 $links = array_merge( $link, $links ); … … 1744 1904 if ( isset( $args['pro_link'] ) ) { 1745 1905 $pro_target = !strstr( $args['pro_link'], '/wp-admin/' ) ? ' target="_blank"' : ''; 1746 $pro_link = '<b><a href="' . esc_url( $args['pro_link'] ) . '"' . $pro_target . '>' . esc_html( __( 'Pro Details' ) ) . '</a></b>';1906 $pro_link = '<b><a href="' . esc_url( $args['pro_link'] ) . '"' . $pro_target . '>' . esc_html( __( 'Pro Details', 'radio-station' ) ) . '</a></b>'; 1747 1907 $link = array( 'pro-details' => $pro_link ); 1748 1908 $links = array_merge( $link, $links ); … … 1758 1918 $addons_url = $args['addons_link']; 1759 1919 $addons_target = !strstr( $addons_url, '/wp-admin/' ) ? ' target="_blank"' : ''; 1760 $addons_link = '<a href="' . esc_url( $addons_url ) . '"' . $addons_target . '>' . esc_html( __( 'Add Ons' ) ) . '</a>';1920 $addons_link = '<a href="' . esc_url( $addons_url ) . '"' . $addons_target . '>' . esc_html( __( 'Add Ons', 'radio-station' ) ) . '</a>'; 1761 1921 $link = array( 'addons' => $addons_link ); 1762 1922 $links = array_merge( $link, $links ); … … 1813 1973 // 1.0.5: use sanitize_title on request variable 1814 1974 // phpcs:ignore WordPress.Security.NonceVerification.Recommended 1815 if ( substr( sanitize_text_field( $_REQUEST['page']), 0, strlen( $args['slug'] ) ) != $args['slug'] ) {1975 if ( substr( sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ), 0, strlen( $args['slug'] ) ) != $args['slug'] ) { 1816 1976 return; 1817 1977 } … … 1826 1986 echo '<h3 class="admin-notices-title" style="cursor:pointer; margin:7px 14px; font-size:16px;" onclick="settings_toggle_notices();">' . "\n"; 1827 1987 echo '<span id="admin-notices-arrow" style="font-size:24px;">▸</span> ' . "\n"; 1828 echo '<span id="admin-notices-title" style="vertical-align:top;">' . esc_html( __( 'Notices' ) ) . '</span> ' . "\n";1988 echo '<span id="admin-notices-title" style="vertical-align:top;">' . esc_html( __( 'Notices', 'radio-station' ) ) . '</span> ' . "\n"; 1829 1989 echo '<span id="admin-notices-count" style="vertical-align:top;"></span></h3>' . "\n"; 1830 1990 … … 1832 1992 echo '</div>' . "\n"; 1833 1993 1834 // --- toggle notice box script --- 1835 echo "<script>function settings_toggle_notices() { 1836 if (document.getElementById('admin-notices-wrap').style.display == '') { 1837 document.getElementById('admin-notices-wrap').style.display = 'none'; 1838 document.getElementById('admin-notices-arrow').innerHTML = '▸'; 1839 } else { 1840 document.getElementById('admin-notices-wrap').style.display = ''; 1841 document.getElementById('admin-notices-arrow').innerHTML= '▾'; 1842 } 1843 } "; 1844 1845 // --- modified from /wp-admin/js/common.js to move notices --- 1846 echo "jQuery(document).ready(function() { 1847 setTimeout(function() { 1848 jQuery('div.update-nag, div.updated, div.error, div.notice').not('.inline, .below-h2').insertAfter(jQuery('#admin-notices-wrap h2')); 1849 count = parseInt(jQuery('#admin-notices-wrap').children().length - 1); 1850 if (count > 0) {jQuery('#admin-notices-count').html('('+count+')');} 1851 else {jQuery('#admin-notices-box').hide();} 1852 }, 500); 1853 });</script>"; 1994 // 1.3.6: move notice boxer scripts to setting_scripts 1995 // $this->scripts[] = 'notice_boxer'; 1854 1996 1855 1997 } … … 1863 2005 $namespace = $this->namespace; 1864 2006 $settings = $GLOBALS[$namespace]; 1865 1866 // --- output debug values ---1867 if ( $this->debug ) {1868 echo '<br><b>Current Settings:</b><br>';1869 // phpcs:ignore WordPress.PHP.DevelopmentFunctions1870 echo esc_html( print_r( $settings, true ) );1871 echo '<br><br>' . "\n";1872 1873 echo '<br><b>Plugin Options:</b><br>';1874 // phpcs:ignore WordPress.PHP.DevelopmentFunctions1875 echo esc_html( print_r( $this->options, true ) );1876 echo '<br><br>' . "\n";1877 1878 // phpcs:ignore WordPress.Security.NonceVerification.Missing1879 if ( isset( $_POST ) ) {1880 echo '<br><b>Posted Values:</b><br>';1881 // phpcs:ignore WordPress.Security.NonceVerification.Missing1882 $posted = array_map( 'sanitize_text_field', $_POST );1883 foreach ( $posted as $key => $value ) {1884 // phpcs:ignore WordPress.PHP.DevelopmentFunctions1885 echo esc_html( $key ) . ': ' . esc_html( print_r( $value, true ) ) . '<br>' . "\n";1886 }1887 }1888 }1889 2007 1890 2008 // --- check for animated gif icon with fallback to normal icon --- … … 1955 2073 // 1.0.8: check if author URL is set 1956 2074 if ( isset( $args['author_url'] ) ) { 1957 echo '<font style="font-size:16px;">' . esc_html( __( 'by' ) ) . '</font> ';2075 echo '<font style="font-size:16px;">' . esc_html( __( 'by', 'radio-station' ) ) . '</font> '; 1958 2076 echo '<a href="' . esc_url( $args['author_url'] ) . '" target="_blank" style="text-decoration:none;font-size:16px;" target="_blank"><b>' . esc_html( $args['author'] ) . '</b></a><br><br>' . "\n"; 1959 2077 } … … 1965 2083 $links = array(); 1966 2084 if ( isset( $args['home'] ) ) { 1967 $links[] = '<a href="' . esc_url( $args['home'] ) . '" class="pluginlink smalllink" title="' . esc_attr( __( 'Plugin Homepage' ) ) . '" target="_blank"><b>' . esc_html( __( 'Home' ) ) . '</b></a>';2085 $links[] = '<a href="' . esc_url( $args['home'] ) . '" class="pluginlink smalllink" title="' . esc_attr( __( 'Plugin Homepage', 'radio-station' ) ) . '" target="_blank"><b>' . esc_html( __( 'Home', 'radio-station' ) ) . '</b></a>'; 1968 2086 } 1969 2087 if ( !isset( $args['readme'] ) || ( false !== $args['readme'] ) ) { 1970 2088 $readme_url = add_query_arg( 'action', $namespace . '_readme_viewer', admin_url( 'admin-ajax.php' ) ); 1971 $links[] = '<a href="' . esc_url( $readme_url ) . '" class="pluginlink smalllink thickbox" title="' . esc_attr( __( 'View Plugin' ) ) . ' readme.txt"><b>' . esc_html( __( 'Readme' ) ) . '</b></a>';2089 $links[] = '<a href="' . esc_url( $readme_url ) . '" class="pluginlink smalllink thickbox" title="' . esc_attr( __( 'View Plugin', 'radio-station' ) ) . ' readme.txt"><b>' . esc_html( __( 'Readme', 'radio-station' ) ) . '</b></a>'; 1972 2090 } 1973 2091 if ( isset( $args['docs'] ) ) { 1974 $links[] = '<a href="' . esc_url( $args['docs'] ) . '" class="pluginlink smalllink" title="' . esc_attr( __( 'Plugin Documentation' ) ) . '" target="_blank"><b>' . esc_html( __( 'Docs' ) ) . '</b></a>';2092 $links[] = '<a href="' . esc_url( $args['docs'] ) . '" class="pluginlink smalllink" title="' . esc_attr( __( 'Plugin Documentation', 'radio-station' ) ) . '" target="_blank"><b>' . esc_html( __( 'Docs', 'radio-station' ) ) . '</b></a>'; 1975 2093 } 1976 2094 if ( isset( $args['support'] ) ) { 1977 $links[] = '<a href="' . esc_url( $args['support'] ) . '" class="pluginlink smalllink" title="' . esc_attr( __( 'Plugin Support' ) ) . '" target="_blank"><b>' . esc_html( __( 'Support' ) ) . '</b></a>';2095 $links[] = '<a href="' . esc_url( $args['support'] ) . '" class="pluginlink smalllink" title="' . esc_attr( __( 'Plugin Support', 'radio-station' ) ) . '" target="_blank"><b>' . esc_html( __( 'Support', 'radio-station' ) ) . '</b></a>'; 1978 2096 } 1979 2097 if ( isset( $args['development'] ) ) { 1980 $links[] = '<a href="' . esc_url( $args['development'] ) . '" class="pluginlink smalllink" title="' . esc_attr( __( 'Plugin Development' ) ) . '" target="_blank"><b>' . esc_html( __( 'Dev' ) ) . '</b></a>';2098 $links[] = '<a href="' . esc_url( $args['development'] ) . '" class="pluginlink smalllink" title="' . esc_attr( __( 'Plugin Development', 'radio-station' ) ) . '" target="_blank"><b>' . esc_html( __( 'Dev', 'radio-station' ) ) . '</b></a>'; 1981 2099 } 1982 2100 … … 2026 2144 $rate_text = $args['ratetext']; 2027 2145 } else { 2028 $rate_text = __( 'Rate on WordPress.Org' );2146 $rate_text = __( 'Rate on WordPress.Org', 'radio-station' ); 2029 2147 } 2030 2148 $rate_link = '<a href="' . esc_url( $rate_url ) . '" class="pluginlink" target="_blank">'; … … 2043 2161 $share_text = $args['sharetext']; 2044 2162 } else { 2045 $share_text = __( 'Share the Plugin Love' );2163 $share_text = __( 'Share the Plugin Love', 'radio-station' ); 2046 2164 } 2047 2165 $share_link = '<a href="' . esc_url( $args['share'] ) . '" class="pluginlink" target="_blank">'; … … 2060 2178 $donate_text = $args['donatetext']; 2061 2179 } else { 2062 $donate_text = __( 'Support this Plugin' );2180 $donate_text = __( 'Support this Plugin', 'radio-station' ); 2063 2181 } 2064 2182 $donate_link = '<a href="' . esc_url( $args['donate'] ) . '" class="pluginlink" target="_blank">'; … … 2078 2196 if ( isset( $_GET['updated'] ) ) { 2079 2197 // phpcs:ignore WordPress.Security.NonceVerification.Recommended 2080 $updated = sanitize_text_field( $_GET['updated']);2198 $updated = sanitize_text_field( wp_unslash( $_GET['updated'] ) ); 2081 2199 if ( 'yes' == $updated ) { 2082 $message = $settings['title'] . ' ' . __( 'Settings Updated.' );2200 $message = $settings['title'] . ' ' . __( 'Settings Updated.', 'radio-station' ); 2083 2201 } elseif ( 'no' == $updated ) { 2084 $message = __( 'Error! Settings NOT Updated.' );2202 $message = __( 'Error! Settings NOT Updated.', 'radio-station' ); 2085 2203 } elseif ( 'reset' == $updated ) { 2086 $message = $settings['title'] . ' ' . __( 'Settings Reset!' );2204 $message = $settings['title'] . ' ' . __( 'Settings Reset!', 'radio-station' ); 2087 2205 } 2088 2206 if ( isset( $message ) ) { … … 2096 2214 // 1.0.5: use sanitize_title on request variable 2097 2215 // phpcs:ignore WordPress.Security.NonceVerification.Recommended 2098 if ( isset( $_REQUEST['welcome'] ) && ( 'true' == sanitize_text_field( $_REQUEST['welcome']) ) ) {2216 if ( isset( $_REQUEST['welcome'] ) && ( 'true' == sanitize_text_field( wp_unslash( $_REQUEST['welcome'] ) ) ) ) { 2099 2217 // 1.2.3: skip output if welcome message argument is empty 2100 2218 if ( isset( $args['welcome'] ) && ( '' != $args['welcome'] ) ) { 2101 2219 echo '<tr><td colspan="3" align="center">'; 2102 // 1.2.5: use direct echo option for message box2103 $this->message_box( $args['welcome'], true );2220 // 1.2.5: use direct echo option for message box 2221 $this->message_box( $args['welcome'], true ); 2104 2222 echo '</td></tr>' . "\n"; 2105 2223 } … … 2153 2271 $options = apply_filters( $namespace . '_options', $options ); 2154 2272 2155 // --- maybe enqueue media scripts ---2156 // 1.1.7: added media gallery script enqueueing for image field2157 // 1.1.7: added color picker and color picker alpha script enqueueing2158 $enqueued_media = $enqueued_color_picker = $enqueue_color_picker = $enqueue_color_picker_alpha = false;2159 foreach ( $options as $option ) {2160 if ( ( 'image' == $option['type'] ) && !$enqueued_media ) {2161 wp_enqueue_media();2162 $enqueued_media = true;2163 } elseif ( 'color' == $option['type'] ) {2164 $enqueue_color_picker = true;2165 } elseif ( 'coloralpha' == $option['type'] ) {2166 $enqueue_color_picker_alpha = true;2167 }2168 }2169 2170 // 1.2.5: moved out of2171 if ( $enqueue_color_picker_alpha ) {2172 wp_enqueue_style( 'wp-color-picker' );2173 $suffix = '.min';2174 if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {2175 $suffix = '';2176 }2177 $url = plugins_url( '/js/wp-color-picker-alpha' . $suffix . '.js', $args['file'] );2178 wp_enqueue_script( 'wp-color-picker-a', $url, array( 'wp-color-picker' ), '3.0.0', true );2179 $enqueued_color_picker = true;2180 } elseif ( $enqueue_color_picker ) {2181 wp_enqueue_style( 'wp-color-picker' );2182 wp_enqueue_script( 'wp-color-picker' );2183 $enqueued_color_picker = true;2184 }2185 2186 2273 $defaults = $this->default_settings(); 2187 2274 $settings = $this->get_settings( false ); … … 2200 2287 2201 2288 $currenttab = ''; 2202 if ( isset( $settings['settingstab'] ) ) { 2289 // 1.3.4: allow for switching setting tab via querystring 2290 if ( isset( $_REQUEST['tab'] ) ) { 2291 $currenttab = sanitize_text_field( wp_unslash( $_REQUEST['tab'] ) ); 2292 } elseif ( isset( $settings['settingstab'] ) ) { 2203 2293 $currenttab = $settings['settingstab']; 2204 2294 } … … 2245 2335 // 1.0.9: add to settings scripts 2246 2336 // 1.2.5: only store script reference 2247 $this->scripts[] = 'tab_switcher';2337 // $this->scripts[] = 'tab_switcher'; 2248 2338 2249 2339 $i = 0; … … 2261 2351 echo '</ul>' . "\n"; 2262 2352 } else { 2263 $tabs = array( 'general' => __( 'General' ) );2353 $tabs = array( 'general' => __( 'General', 'radio-station' ) ); 2264 2354 } 2265 2355 2266 2356 // --- reset to default script --- 2267 2357 // 1.0.9: add to settings scripts 2268 $this->scripts[] = 'settings_reset';2358 // $this->scripts[] = 'settings_reset'; 2269 2359 2270 2360 // --- start settings form --- … … 2353 2443 $buttons .= '<tr><td align="center">' . "\n"; 2354 2444 // 1.2.5: remove reset onclick attribute 2355 $buttons .= '<input type="button" id="settingsresetbutton" class="button-secondary settings-button" value="' . esc_attr( __( 'Reset Settings' ) ) . '">' . "\n";2445 $buttons .= '<input type="button" id="settingsresetbutton" class="button-secondary settings-button" value="' . esc_attr( __( 'Reset Settings', 'radio-station' ) ) . '">' . "\n"; 2356 2446 $buttons .= '</td><td colspan="3"></td><td align="center">' . "\n"; 2357 $buttons .= '<input type="submit" class="button-primary settings-button" value="' . esc_attr( __( 'Save Settings' ) ) . '">' . "\n";2447 $buttons .= '<input type="submit" class="button-primary settings-button" value="' . esc_attr( __( 'Save Settings', 'radio-station' ) ) . '">' . "\n"; 2358 2448 $buttons .= '</td></tr>' . "\n"; 2359 2449 $buttons .= '<tr height="25"><td></td></tr>' . "\n"; … … 2383 2473 2384 2474 // --- enqueue settings resources --- 2385 $this->settings_resources( $enqueued_media, $enqueued_color_picker );2475 // 1.3.4: moved settings resources enqueue to admin_enqueue_scripts 2386 2476 } 2387 2477 … … 2456 2546 public function settings_resources( $media = true, $color_picker = true ) { 2457 2547 2548 // 1.3.5: set default scripts to enqueue 2549 $this->scripts = array( 'notice_boxer', 'tab_switcher', 'settings_reset' ); 2550 2458 2551 // --- number input step script --- 2459 2552 // 1.0.9: added to script array … … 2473 2566 2474 2567 // --- enqueue settings scripts --- 2475 add_action( 'admin_footer', array( $this, 'setting_scripts' ) ); 2568 // 1.3.4: change from admin_footer hook 2569 // 1.3.5: change back to admin_footer hook (for jQuery!) 2570 // 1.3.6: enqueue and append to dummy admin script 2571 // add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); 2572 // add_action( 'admin_footer', array( $this, 'setting_scripts' ) ); 2573 $this->enqueue_scripts(); 2476 2574 2477 2575 // --- enqueue settings styles --- 2478 add_action( 'admin_footer', array( $this, 'setting_styles' ) ); 2576 // 1.3.4: change from admin_footer hook 2577 // 1.3.6: enqueue and append to dummy admin style 2578 // add_action( 'admin_enqueue_styles', array( $this, 'enqueue_styles' ) ); 2579 // add_action( 'admin_print_styles', array( $this, 'setting_styles' ) ); 2580 $this->enqueue_styles(); 2479 2581 2480 2582 } … … 2542 2644 $row .= '<td class="settings-label">' . $option['label'] . "\n"; 2543 2645 if ( 'multiselect' == $type ) { 2544 $row .= '<br><span>' . esc_html( __( 'Use Ctrl and Click to Select' ) ) . '</span>' . "\n";2646 $row .= '<br><span>' . esc_html( __( 'Use Ctrl and Click to Select', 'radio-station' ) ) . '</span>' . "\n"; 2545 2647 } 2546 2648 $row .= '</td><td width="25"></td>' . "\n"; … … 2581 2683 if ( $upgrade_link || isset( $pro_link ) ) { 2582 2684 // 1.2.2: change text from Available in Pro 2583 $row .= __( 'Premium Feature.' ) . '<br>';2685 $row .= __( 'Premium Feature.', 'radio-station' ) . '<br>'; 2584 2686 if ( $upgrade_link ) { 2585 $row .= '<a href="' . esc_url( $upgrade_link ) . '"' . $upgrade_target . '>' . esc_html( __( 'Upgrade Now' ) ) . '</a>';2687 $row .= '<a href="' . esc_url( $upgrade_link ) . '"' . $upgrade_target . '>' . esc_html( __( 'Upgrade Now', 'radio-station' ) ) . '</a>'; 2586 2688 } 2587 2689 if ( $upgrade_link && isset( $pro_link ) ) { … … 2592 2694 // 1.3.0: add hash link anchor for Pro feature options 2593 2695 $option_anchor = str_replace( '_', '-', $option['key'] ); 2594 $row .= '<a href="' . esc_url( $pro_link ) . '#' . esc_attr( $option_anchor ) . '"' . $pro_target . '>' . esc_html( __( 'Details' ) ) . '</a>' . "\n";2696 $row .= '<a href="' . esc_url( $pro_link ) . '#' . esc_attr( $option_anchor ) . '"' . $pro_target . '>' . esc_html( __( 'Details', 'radio-station' ) ) . '</a>' . "\n"; 2595 2697 } 2596 2698 } else { 2597 $row .= esc_html( __( 'Coming soon in Pro version!' ) );2699 $row .= esc_html( __( 'Coming soon in Pro version!', 'radio-station' ) ); 2598 2700 } 2599 2701 $row .= '</td>' . "\n"; … … 2917 3019 } 2918 3020 $row .= '<a class="upload-custom-image' . esc_attr( $hidden ) . '" href="' . esc_url( $upload_link ) . '">' . "\n"; 2919 $row .= esc_html( __( 'Add Image' ) );3021 $row .= esc_html( __( 'Add Image', 'radio-station' ) ); 2920 3022 $row .= '</a>' . "\n"; 2921 3023 … … 2925 3027 } 2926 3028 $row .= '<a class="delete-custom-image' . esc_attr( $hidden ) . '" href="#">' . "\n"; 2927 $row .= esc_html( __( 'Remove Image' ) );3029 $row .= esc_html( __( 'Remove Image', 'radio-station' ) ); 2928 3030 $row .= '</a>' . "\n"; 2929 3031 $row .= '</p>' . "\n"; … … 2963 3065 2964 3066 return $row; 3067 } 3068 3069 // --------------- 3070 // Enqueue Scripts 3071 // --------------- 3072 // 1.3.6: enqueue scripts inline via dummy script 3073 public function enqueue_scripts() { 3074 3075 $version = $this->plugin_version(); 3076 wp_register_script( 'plugin-admin-settings', null, array( 'jquery' ), $version, true ); 3077 wp_enqueue_script( 'plugin-admin-settings' ); 3078 $js = $this->setting_scripts(); 3079 wp_add_inline_script( 'plugin-admin-settings', $js, 'after' ); 3080 2965 3081 } 2966 3082 … … 2973 3089 $args = $this->args; 2974 3090 $scripts = $this->scripts; 3091 2975 3092 if ( count( $scripts ) > 0 ) { 2976 echo "<script>"; 3093 3094 // 1.3.6: buffer script output 3095 ob_start(); 3096 2977 3097 foreach ( $scripts as $script ) { 2978 3098 … … 3000 3120 echo "});" . "\n"; 3001 3121 3122 } elseif ( 'notice_boxer' == $script ) { 3123 3124 // --- toggle notice box script --- 3125 echo "function settings_toggle_notices() { 3126 if (document.getElementById('admin-notices-wrap').style.display == '') { 3127 document.getElementById('admin-notices-wrap').style.display = 'none'; 3128 document.getElementById('admin-notices-arrow').innerHTML = '▸'; 3129 } else { 3130 document.getElementById('admin-notices-wrap').style.display = ''; 3131 document.getElementById('admin-notices-arrow').innerHTML= '▾'; 3132 } 3133 }" . "\n"; 3134 3135 // --- modified from /wp-admin/js/common.js to move notices --- 3136 echo "jQuery(document).ready(function() { 3137 setTimeout(function() { 3138 jQuery('div.update-nag, div.updated, div.error, div.notice').not('.inline, .below-h2').insertAfter(jQuery('#admin-notices-wrap h2')); 3139 count = parseInt(jQuery('#admin-notices-wrap').children().length - 1); 3140 if (count > 0) {jQuery('#admin-notices-count').html('('+count+')');} 3141 else {jQuery('#admin-notices-box').hide();} 3142 }, 500); 3143 });" . "\n"; 3144 3002 3145 } elseif ( 'settings_reset' == $script ) { 3003 3146 … … 3005 3148 // 1.2.5: changed function prefix for consistency 3006 3149 // 1.2.5: changed to jQuery click function to remove onclick button attribute 3007 $confirmreset = __( 'Are you sure you want to reset to default settings?' );3150 $confirmreset = __( 'Are you sure you want to reset to default settings?', 'radio-station' ); 3008 3151 // echo "function plugin_panel_reset_defaults() {" . "\n"; 3009 3152 echo "jQuery('#settingsresetbutton').on('click', function() {" . "\n"; … … 3046 3189 3047 3190 // --- media functions --- 3048 $confirm_remove = __( 'Are you sure you want to remove this image?' );3191 $confirm_remove = __( 'Are you sure you want to remove this image?', 'radio-station' ); 3049 3192 echo "jQuery(function(){ 3050 3193 … … 3102 3245 3103 3246 } 3104 // else { 3105 // [no longer implemented - no escape option] 3106 // echo $script; 3107 // } 3247 3108 3248 } 3109 3249 3110 3250 // 1.2.5: added for possible extra settings scripts 3111 3251 do_action( $args['namespace'] . '_settings_scripts', $args ); 3112 3113 echo "</script>"; 3114 } 3252 3253 $js = ob_get_contents(); 3254 ob_end_clean(); 3255 return $js; 3256 3257 } 3258 } 3259 3260 // -------------- 3261 // Enqueue Styles 3262 // -------------- 3263 // 1.3.6: enqueue styles inline via dummy stylesheet 3264 public function enqueue_styles() { 3265 3266 $version = $this->plugin_version(); 3267 wp_register_style( 'plugin-admin-settings', null, array(), $version, 'all' ); 3268 wp_enqueue_style( 'plugin-admin-settings' ); 3269 $css = $this->setting_styles(); 3270 wp_add_inline_style( 'plugin-admin-settings', $css ); 3271 3115 3272 } 3116 3273 … … 3188 3345 $namespace = $this->namespace; 3189 3346 $styles = apply_filters( $namespace . '_admin_page_styles', $styles ); 3347 $styles_string = implode( "\n", $styles ); 3348 3190 3349 // 1.2.5: added wp_strip_all_tags to styles output 3191 3350 // 1.3.0: use wp_kses_post on styles output 3192 // echo wp_strip_all_tags( implode( "\n", $styles ) );3193 echo "<style>" . wp_kses_post( implode( "\n", $styles ) ) . "</style>";3194 3351 // 1.3.6: return style string instead of echo 3352 // echo wp_strip_all_tags( istyles_string ) ); 3353 return $styles_string; 3195 3354 } 3196 3355 … … 3463 3622 3464 3623 // ========= 3465 // STRUCTURE3466 // =========3467 //3468 // === Loader Class ===3469 // - Initialize Loader3470 // - Setup Plugin3471 // - Get Plugin Data3472 // - Get Plugin Version3473 // - Set Pro Namespace3474 // === Plugin Settings ===3475 // - Get Default Settings3476 // - Add Settings3477 // - Maybe Transfer Settings3478 // - Get All Plugin Settings3479 // - Get Plugin Setting3480 // - Reset Plugin Settings3481 // - Update Plugin Settings3482 // - Validate Plugin Setting3483 // === Plugin Loading ===3484 // - Load Plugin Settings3485 // - Add Actions3486 // - Load Helper Libraries3487 // - Maybe Load Thickbox3488 // - Readme Viewer AJAX3489 // === Freemius Loading ===3490 // - Load Freemius3491 // - Filter Freemius Connect3492 // - Freemius Connect Message3493 // - Connect Update Message3494 // === Plugin Admin ===3495 // - Add Settings Menu3496 // - Plugin Page Links3497 // - Message Box3498 // - Notice Boxer3499 // - Plugin Page Header3500 // - Settings Page3501 // - Settings Table3502 // - Setting Row3503 // - Settings Scripts3504 // - Settings Styles3505 // === Namespaced Functions ===3506 3507 3508 // =========3509 3624 // CHANGELOG 3510 3625 // ========= 3626 3627 // == 1.3.4 == 3628 // - switch to settings tab via querystring 3629 // - enqueue settings page resources earlier 3630 3631 // == 1.3.3 == 3632 // - move post debug output to after check_admin_referer 3633 3634 // == 1.3.2 == 3635 // - added isset and wp_unslash to $_REQUEST inputs 3636 3637 // == 1.3.1 == 3638 // - use prefixed markdown reader function 3639 // - when reading strip any license lines causing breakage 3640 // - update to color picker alpha library (3.0.4) 3641 // - added text domain to translation wrappers (for replacing) 3511 3642 3512 3643 // == 1.3.0 == -
adminsanity/trunk/readme.md
r3115930 r3316572 4 4 Tags: wordpress admin, admin menu, admin notices, admin bar, cleaner 5 5 Requires at least: 4.0.0 6 Tested up to: 6. 5.57 Stable tag: 1.0. 36 Tested up to: 6.8.1 7 Stable tag: 1.0.4 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 124 124 == Changelog == 125 125 126 = 1.0.4 = 127 * Updated: Plugin Panel (1.3.5) 128 * Fixed: Admin Bar Frontend module loading option key 129 126 130 = 1.0.3 = 127 131 * Improved: do not load Menu/Notices on Block Editor pages -
adminsanity/trunk/readme.txt
r3115930 r3316572 4 4 Tags: wordpress admin, admin menu, admin notices, admin bar, cleaner 5 5 Requires at least: 4.0.0 6 Tested up to: 6. 5.57 Stable tag: 1.0. 36 Tested up to: 6.8.1 7 Stable tag: 1.0.4 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 124 124 == Changelog == 125 125 126 = 1.0.4 = 127 * Updated: Plugin Panel (1.3.5) 128 * Fixed: Admin Bar Frontend module loading option key 129 126 130 = 1.0.3 = 127 131 * Improved: do not load Menu/Notices on Block Editor pages
Note: See TracChangeset
for help on using the changeset viewer.