'https://wordpress.org', 'wq' => 'https://wordquest.org', 'wpm' => 'https://wpmedic.tech', 'prn' => 'https://pluginreview.net', 'bio' => 'https://bioship.space', ); // ------------------------ // Set Debug Switch Default // ------------------------ // 1.6.6: set debug switch to off to recheck later global $wqdebug; $wqdebug = false; // ----------------------------------------- // === Version Handling Loader Functions === // ----------------------------------------- // ...future proof helper update library... // ---------------------------------- // Add Helper version to global array // ---------------------------------- // 1.6.0: change globals to use new variable functions (as not backcompatible!) global $wordquesthelpers, $wqfunctions; if ( !is_array( $wordquesthelpers ) ) { $wordquesthelpers = array( $wqhv ); } elseif ( !in_array( $wqhv, $wordquesthelpers ) ) { $wordquesthelpers[] = $wqhv; } // ------------------------------------------ // Set Latest Wordquest Version on Admin Load // ------------------------------------------ // 1.5.0: use admin_init not plugins_loaded so as to be usable by themes // 1.8.0: remove unnecessary third parameter if ( !has_action( 'admin_init', 'wqhelper_admin_loader' ) ) { add_action( 'admin_init', 'wqhelper_admin_loader', 1 ); } if ( !function_exists( 'wqhelper_admin_loader' ) ) { function wqhelper_admin_loader() { global $wqdebug; // --- maybe set debug mode --- // 1.6.6: check debug switch here so we can check permissions if ( current_user_can( 'manage_options' ) ) { // 1.8.1: use sanitize_text_field on request variable // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( isset( $_REQUEST['wqdebug'] ) && in_array( sanitize_title( $_REQUEST['wqdebug'] ), array( '1', 'yes' ) ) ) { $wqdebug = true; } } // --- maybe remove old action --- // 1.6.0: maybe remove the pre 1.6.0 loader action if ( has_action( 'admin_init', 'wordquest_admin_load' ) ) { remove_action( 'admin_init', 'wordquest_admin_load' ); } // --- set helper version to use --- // 1.6.0: new globals used for new method global $wordquesthelper, $wordquesthelpers; $wordquesthelper = max( $wordquesthelpers ); if ( $wqdebug ) { // phpcs:ignore WordPress.PHP.DevelopmentFunctions echo ""; echo ""; } // --- load callable functions --- // 1.6.0: set the function caller helper global $wqcaller, $wqfunctions; $functionname = 'wqhelper_caller_'; $func = $functionname . $wordquesthelper; if ( $wqdebug ) { echo ""; } // --- set callable functions --- if ( is_callable( $wqfunctions[$func] ) ) { $wqfunctions[$func]( $functionname ); } elseif ( function_exists( $func ) ) { call_user_func( $func, $functionname ); } if ( $wqdebug ) { // phpcs:ignore WordPress.PHP.DevelopmentFunctions echo ""; } // --- load admin notices --- // 1.5.0: set up any admin notices via helper version // 1.6.0: ...use caller function directly for this $adminnotices = 'wqhelper_admin_notices'; if ( is_callable( $wqcaller ) ) { $wqcaller( $adminnotices ); } elseif ( function_exists( $adminnotices ) ) { call_user_func( $adminnotices ); } } } // ---------------------------------- // Function to Define Function Caller // ---------------------------------- // 1.6.0: some lovely double abstraction here! $funcname = 'wqhelper_caller_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function( $func ) { global $wqfunctions, $wqcaller; if ( !is_callable( $wqcaller ) ) { $wqcaller = function( $function, $args = null ) { global $wordquesthelper, $wqfunctions; $func = $function . '_' . $wordquesthelper; // echo ""; if ( is_callable( $wqfunctions[$func] ) ) { return $wqfunctions[$func]( $args ); } elseif ( function_exists( $func ) ) { return call_user_func( $func, $args ); } // 1.8.0: added missing return null statement return null; }; } }; } // ------------------------------------- // Versioned Admin Page Caller Functions // ------------------------------------- // 1.7.2: use direct superglobal to shorten functions // wqhelper_admin_page // wqhelper_admin_notice_boxer // wqhelper_get_plugin_info // wqhelper_admin_plugins_column // wqhelper_admin_feeds_column // wqhelper_install_plugin // wqhelper_reminder_notice // wqhelper_translate // --- admin page --- if ( !function_exists( 'wqhelper_admin_page' ) ) { function wqhelper_admin_page( $args = null ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // --- admin notice boxer --- if ( !function_exists( 'wqhelper_admin_notice_boxer' ) ) { function wqhelper_admin_notice_boxer( $args = null ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // --- get plugins info --- if ( !function_exists( 'wqhelper_get_plugin_info' ) ) { function wqhelper_get_plugin_info( $args = null ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // --- admin page plugins column --- if ( !function_exists( 'wqhelper_admin_plugins_column' ) ) { function wqhelper_admin_plugins_column( $args = null ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // --- admin page feeds column --- if ( !function_exists( 'wqhelper_admin_feeds_column' ) ) { function wqhelper_admin_feeds_column( $args = null ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // 1.6.5: install WordQuest plugin if ( !function_exists( 'wqhelper_install_plugin' ) ) { function wqhelper_install_plugin( $args = null ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // 1.6.5: reminder notice message if ( !function_exists( 'wqhelper_reminder_notice' ) ) { function wqhelper_reminder_notice( $args = null ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // 1.6.9: translation wrapper if ( !function_exists( 'wqhelper_translate' ) ) { function wqhelper_translate( $string ) { return $GLOBALS['wqcaller']( __FUNCTION__, $string ); } } // --------------------------------- // Sidebar Floatbox Caller Functions // --------------------------------- // 1.7.2: use direct superglobal to shorten functions // 1.7.4: added patreon wrapper function // - wqhelper_sidebar_floatbox // - wqhelper_sidebar_patreon_button // - wqhelper_sidebar_paypal_donations // - wqhelper_sidebar_testimonial_box // - wqhelper_sidebar_floatmenuscript // - wqhelper_sidebar_stickykitscript // --- sidebar floatbox --- if ( !function_exists( 'wqhelper_sidebar_floatbox' ) ) { function wqhelper_sidebar_floatbox( $args = null ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // --- patreon supporters button --- if ( !function_exists( 'wqhelper_sidebar_patreon_button' ) ) { function wqhelper_sidebar_patreon_button( $args = null ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // --- paypal donations button --- if ( !function_exists( 'wqhelper_sidebar_paypal_donations' ) ) { function wqhelper_sidebar_paypal_donations( $args = null ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // --- testimonials box --- if ( !function_exists( 'wqhelper_sidebar_testimonial_box' ) ) { function wqhelper_sidebar_testimonial_box( $args = null ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // --- floating menu script --- if ( !function_exists( 'wqhelper_sidebar_floatmenuscript' ) ) { function wqhelper_sidebar_floatmenuscript( $args = null ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // --- sticky kit script --- if ( !function_exists( 'wqhelper_sidebar_stickykitscript' ) ) { function wqhelper_sidebar_stickykitscript( $args = null ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // Dashboard Feed Caller Functions // ------------------------------- // 1.7.2: use direct superglobal to shorten functions // - wqhelper_add_dashboard_feed_widget // - wqhelper_dashboard_feed_javascript // - wqhelper_dashboard_feed_widget // - wqhelper_pluginreview_feed_widget // - wqhelper_process_rss_feed // - wqhelper_load_category_feed // - wqhelper_get_feed_ad // --- add dashboard feed widget --- if ( !function_exists( 'wqhelper_add_dashboard_feed_widget' ) ) { function wqhelper_add_dashboard_feed_widget( $args = null ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // --- dashboard feed javascript --- if ( !function_exists( 'wqhelper_dashboard_feed_javascript' ) ) { function wqhelper_dashboard_feed_javascript( $args = null ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // --- dashboard feed widget --- if ( !function_exists( 'wqhelper_dashboard_feed_widget' ) ) { function wqhelper_dashboard_feed_widget( $args = null ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // --- plugin review feed widget --- if ( !function_exists( 'wqhelper_pluginreview_feed_widget' ) ) { function wqhelper_pluginreview_feed_widget( $args = null ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // --- process RSS feed --- if ( !function_exists( 'wqhelper_process_rss_feed' ) ) { function wqhelper_process_rss_feed( $args = null ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // --- load category feed --- if ( !function_exists( 'wqhelper_load_category_feed' ) ) { function wqhelper_load_category_feed( $args = null ) { // 1.7.7: simplified admin condition logic if ( is_admin() ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } // 1.8.0: added missing empty return return ''; } } // --- get feed ad --- // 1.8.0: added feed ad wrapper function if ( !function_exists( 'wqhelper_get_feed_ad' ) ) { function wqhelper_get_feed_ad( $args = null ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // -------------------------- // === Styles and Scripts === // -------------------------- // --------------------------------- // Add Helper Styles to Admin Footer // --------------------------------- if ( !has_action( 'admin_footer', 'wqhelper_admin_styles' ) ) { add_action( 'admin_footer', 'wqhelper_admin_styles' ); } if ( !function_exists( 'wqhelper_admin_styles' ) ) { function wqhelper_admin_styles( $args = null ) { remove_action( 'admin_footer', 'wordquest_admin_styles' ); return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // ---------------------------------- // Add Helper Scripts to Admin Footer // ---------------------------------- if ( !has_action( 'admin_footer', 'wqhelper_admin_scripts' ) ) { add_action( 'admin_footer', 'wqhelper_admin_scripts' ); } if ( !function_exists( 'wqhelper_admin_scripts' ) ) { function wqhelper_admin_scripts( $args = null ) { remove_action( 'admin_footer', 'wordquest_admin_scripts' ); return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // ---------------------- // === AJAX Functions === // ---------------------- // AJAX for reminder dismissal // --------------------------- // 1.6.5: added this AJAX function if ( !has_action( 'wp_ajax_wqhelper_reminder_dismiss', 'wqhelper_reminder_dismiss' ) ) { add_action( 'wp_ajax_wqhelper_reminder_dismiss', 'wqhelper_reminder_dismiss' ); } if ( !function_exists( 'wqhelper_reminder_dismiss' ) ) { function wqhelper_reminder_dismiss( $args = null ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // ----------------------- // AJAX Load Category Feed // ----------------------- if ( !has_action( 'wp_ajax_wqhelper_load_feed_cat', 'wqhelper_load_feed_category' ) ) { add_action( 'wp_ajax_wqhelper_load_feed_cat', 'wqhelper_load_feed_category' ); } if ( !function_exists( 'wqhelper_load_feed_category' ) ) { function wqhelper_load_feed_category( $args = null ) { return $GLOBALS['wqcaller']( __FUNCTION__, $args ); } } // ---------------------- // Update Sidebar Options // ---------------------- // 1.6.0: ! NOTE ! caller exception ! use matching form version function here just in case... if ( !has_action( 'wp_ajax_wqhelper_update_sidebar_boxes', 'wqhelper_update_sidebar_boxes' ) ) { add_action( 'wp_ajax_wqhelper_update_sidebar_boxes', 'wqhelper_update_sidebar_boxes' ); } if ( !function_exists( 'wqhelper_update_sidebar_boxes' ) ) { function wqhelper_update_sidebar_boxes() { // --- get helper version --- // phpcs:ignore WordPress.Security.NonceVerification.Missing if ( !isset( $_POST['wqhv'] ) ) { return; } else { // 1.8.1: sanitize to integer and cast to string // phpcs:ignore WordPress.Security.NonceVerification.Missing $wqhv = (string) absint( $_POST['wqhv'] ); } // 1.6.6: added sanitization of version value // 1.8.1: simplified to check for 3 digits only if ( strlen( $wqhv ) !== 3 ) { return; } // --- set matching function version --- $func = 'wqhelper_update_sidebar_options_' . $wqhv; // --- call function --- // 1.6.5: fix to function call method global $wqfunctions; if ( is_callable( $wqfunctions[$func] ) ) { $wqfunctions[$func](); } elseif ( function_exists( $func ) ) { call_user_func( $func ); } } } // ---------------------------------- // === Version Specific Functions === // ---------------------------------- // (functions below this point must be suffixed with _{VERSION} to work // and update with each plugin helper version regardless of change state) // ------------------- // Translation Wrapper // ------------------- // 1.6.9: check translated labels global $funcname = 'wqhelper_translate_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function( $string ) { global $wqlabels; if ( isset( $wqlabels[$string] ) ) { return $wqlabels[$string]; } // 1.6.9: added fallback translation for bioship theme if ( function_exists( 'bioship_translate' ) ) { return bioship_translate( $string ); } if ( function_exists( 'translate' ) ) { // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText return translate( (string) $string, 'default' ); } return $string; }; } // ------------------ // Admin Notice Boxer // ------------------ // (for settings pages) $funcname = 'wqhelper_admin_notice_boxer_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function() { // 1.7.7: bug out if already using AdminSanity Notices box // 1.7.8: replace with better check for AdminSanity Notices box global $adminsanity; if ( isset( $adminsanity ) && isset( $adminsanity['load'] ) && $adminsanity['load']['notices'] ) { return; } // --- count admin notices --- // global $wp_filter; $notices = 0; // print_r($wp_filter); // if (isset($wp_filter['admin_notices'])) {$adminnotices = $notices = count($wp_filter['admin_notices']);} // if (is_network_admin()) {if (isset($wp_filter['network_admin_notices'])) {$networknotices = count($wp_filter['network_admin_notices']); $notices = $notices + $networknotices;} } // if (is_user_admin()) {if (isset($wp_filter['user_admin_notices'])) {$usernotices = count($wp_filter['user_admin_notices']); $notices = $notices + $usernotices;} } // if (isset($wp_filter['all_admin_notices'])) {$alladminnotices = count($wp_filter['all_admin_notices']); $notices = $notices + $alladminnotices;} // if ($notices == 0) {return;} // print_r($wp_filter['admin_notices']); print_r($wp_filter['all_admin_notices']); // echo ""; // --- toggle notice box script --- echo ""; // --- output notice box --- echo '
'; echo '

'; echo '▾   '; echo esc_html( wqhelper_translate( 'Admin Notices' ) ); echo '

'; }; } // --------------------------- // Usage Reminder Notice Check // --------------------------- // 1.5.0: added reminder prototype that does nothing yet // 1.6.5: completed usage reminder notices $funcname = 'wqhelper_admin_notices_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function() { global $wordquestplugins; foreach ( $wordquestplugins as $pluginslug => $wqplugin ) { // --- check current user capabilities --- // 1.7.3: only show reminder notice to users with capabilities $shownotice = false; if ( current_user_can( 'manage_options' ) || ( ( 'bioship' == $pluginslug ) && current_user_can( 'install_themes' ) ) || ( ( 'bioship' != $pluginslug ) && current_user_can( 'install_plugins' ) ) ) { $shownotice = true; } if ( $shownotice ) { // 1.6.8: move here to fix undefined index warning $prefix = $wqplugin['settings']; // 1.7.0: moved up here to fix install version check $sidebaroptions = get_option( $prefix . '_sidebar_options' ); // 1.6.7: maybe set first install version for plugin if ( !isset( $sidebaroptions['installversion'] ) ) { $sidebaroptions['installversion'] = $wqplugin['version']; update_option( $prefix . '_sidebar_options', $sidebaroptions ); } // 1.6.5: no reminders needed if pro version // 1.7.7: added check if plan key is set for back-compat if ( isset( $wqplugin['plan'] ) && ( 'premium' == $wqplugin['plan'] ) ) { return; } // 1.6.5: no reminders if donation box has been turned off // 1.6.7: revert that as so many other ways to still contribute // if ( (isset($sidebaroptions['donationboxoff'])) // && ($sidebaroptions['donationboxoff'] == 'checked') ) {return;} if ( isset( $sidebaroptions['installdate'] ) ) { // --- check usage length --- $reminder = false; $installtime = strtotime( $sidebaroptions['installdate'] ); $timesince = time() - $installtime; $dayssince = floor( $timesince / ( 24 * 60 * 60 ) ); // --- 30 days, 90 days and 1 year notices --- if ( $dayssince > 365 ) { // --- 365 day notice --- if ( !isset( $sidebaroptions['365days'] ) ) { $reminder = '365'; } } elseif ( $dayssince > 90 ) { // --- 90 day notice --- if ( !isset( $sidebaroptions['90days'] ) ) { $reminder = '90'; } } elseif ( $dayssince > 30 ) { // --- 30 day notice --- if ( !isset( $sidebaroptions['30days'] ) ) { $reminder = '30'; } } if ( $reminder ) { // --- add an admin reminder notice --- global $wqreminder; $wqreminder[$pluginslug] = $wqplugin; $wqreminder[$pluginslug]['days'] = $dayssince; $wqreminder[$pluginslug]['notice'] = $reminder; add_action( 'admin_notices', 'wqhelper_reminder_notice' ); } } else { $sidebaroptions['installdate'] = date( 'Y-m-d' ); update_option( $prefix . '_sidebar_options', $sidebaroptions ); } } } }; } // --------------------- // Usage Reminder Notice // --------------------- // 1.6.5: added reminder notice text $funcname = 'wqhelper_reminder_notice_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function() { global $wqreminder, $wqurls, $wordquestplugins; // --- loop reminders --- foreach ( $wqreminder as $pluginslug => $reminder ) { // --- reminder wrapper --- echo '
'; echo esc_html( wqhelper_translate( "You've been enjoying" ) ) . ' '; echo esc_html( $wqreminder[$pluginslug]['title'] ) . ' ' . esc_html( wqhelper_translate( 'for' ) ) . ' '; echo esc_html( $wqreminder[$pluginslug]['days'] ) . ' ' . esc_html( wqhelper_translate( 'days' ) ) . '. '; echo esc_html( wqhelper_translate( "If you like it, here's some ways you can help make it better" ) ) . ':
'; // Action Links Table // ------------------ // 1.6.7: extended link anchor text for clarity echo '
'; echo ''; echo ''; // --- dismiss notice X link --- $dismisslink = admin_url( 'admin-ajax.php' ) . '?action=wqhelper_reminder_dismiss&slug=' . $pluginslug . '¬ice=' . $wqreminder[$pluginslug]['notice']; echo ''; echo '
'; echo '
'; } // --- notice styles --- // 1.7.5: added notice styling echo ""; // --- notice dismissal iframe --- echo ''; }; } // ----------------------- // AJAX Reminder Dismisser // ----------------------- $funcname = 'wqhelper_reminder_dismiss_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function() { // --- check conditions --- // phpcs:ignore WordPress.Security.NonceVerification.Recommended $pluginslug = sanitize_title( $_REQUEST['slug'] ); // 1.8.1: sanitize to integer and validate against array // phpcs:ignore WordPress.Security.NonceVerification.Recommended $notice = absint( $_REQUEST['notice'] ); if ( !in_array( $notice, array( 30, 90, 365 ) ) ) { return; } // --- check capabilities --- $dismiss = false; if ( current_user_can( 'manage_options' ) || ( ( 'bioship' == $pluginslug ) && current_user_can( 'install_themes' ) ) || ( ( 'bioship' != $pluginslug ) && current_user_can( 'install_plugins' ) ) ) { $dismiss = true; } if ( $dismiss ) { // --- dismiss the reminder notice --- global $wordquestplugins; $prefix = $wordquestplugins[$pluginslug]['settings']; $sidebaroptions = get_option( $prefix . '_sidebar_options' ); if ( isset( $sidebaroptions[$notice . 'days'] ) && ( 'dismissed' == $sidebaroptions[$notice . 'days'] ) ) { $sidebaroptions[$notice . 'days'] = ''; } else { $sidebaroptions[$notice . 'days'] = 'dismissed'; } update_option( $prefix . '_sidebar_options', $sidebaroptions ); // --- hide the notice in the parent window --- echo ""; } exit; }; } // -------------------------- // Get WordQuest Plugins Info // -------------------------- $funcname = 'wqhelper_get_plugin_info_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function() { global $wqurls, $wqdebug; // --- maybe get cached plugin info --- // 1.5.0: get plugin info (maximum twice daily) $plugininfo = get_transient( 'wordquest_plugin_info' ); // clear transient when debugging if ( $wqdebug ) { $plugininfo = ''; } // --- maybe get plugin info now --- if ( !$plugininfo || ( '' == $plugininfo ) || !is_array( $plugininfo ) ) { $pluginsurl = $wqurls['wq'] . '/?get_plugins_info=yes'; $args = array( 'timeout' => 15 ); $plugininfo = wp_remote_get( $pluginsurl, $args ); if ( !is_wp_error( $plugininfo ) ) { $plugininfo = $plugininfo['body']; $dataend = "*****END DATA*****"; if ( strstr( $plugininfo, $dataend ) ) { $pos = strpos( $plugininfo, $dataend ); $plugininfo = substr( $plugininfo, 0, $pos ); $plugininfo = json_decode( $plugininfo, true ); set_transient( 'wordquest_plugin_info', $plugininfo, ( 12 * 60 * 60 ) ); } else { $plugininfo = ''; } } else { $plugininfo = ''; } } if ( $wqdebug ) { // phpcs:ignore WordPress.PHP.DevelopmentFunctions echo ""; } return $plugininfo; }; } // --------------------------- // Version Specific Admin Page // --------------------------- $funcname = 'wqhelper_admin_page_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function() { global $wordquesthelper, $wordquestplugins, $wqurls; echo '
'; // --- admin notice boxer --- wqhelper_admin_notice_boxer(); // --- toggle metabox script --- echo ""; // --- admin page styles --- echo ''; // --- Floating Sidebar --- // set dummy "plugin" values for admin page sidebar global $wordquestplugins, $wordquesthelper; $wordquestplugins['wordquest'] = array( 'version' => $wordquesthelper, 'title' => 'WordQuest Alliance', 'namespace' => 'wordquest', 'settings' => 'wq', 'plan' => 'free', 'wporg' => false, 'wporgslug' => false, ); $args = array( 'wordquest', 'special' ); wqhelper_sidebar_floatbox( $args ); // --- load sticky kit on sidebar --- // 1.6.5: replace floatmenu with stickykit // 1.8.1: use new echo argument on stickykit function wqhelper_sidebar_stickykitscript( true ); echo ""; echo ""; unset( $wordquestplugins['wordquest'] ); // echo wqhelper_sidebar_floatmenuscript(); // echo ' // --- Admin Page Title --- $wordquesticon = plugins_url( 'images/wordquest.png', __FILE__ ); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
' . esc_attr( wqhelper_translate( 'WordQuest icon' ) ) . '

→ ' . esc_html( wqhelper_translate( 'Join' ) ) . '

/

' . esc_html( wqhelper_translate( 'Login' ) ) . '

→ ' . esc_html( wqhelper_translate( 'Solutions' ) ) . '

→ ' . esc_html( wqhelper_translate( 'Contribute' ) ) . '

'; // --- Output Plugins Column --- wqhelper_admin_plugins_column( null ); // --- Output Feeds Column --- wqhelper_admin_feeds_column( null ); // --- Wordquest Sidebar 'plugin' box --- if ( !function_exists( 'wq_sidebar_plugin_footer' ) ) { function wq_sidebar_plugin_footer() { global $wqurls; $iconurl = plugins_url( 'images/wordquest.png', __FILE__ ); echo '

' . esc_html( wqhelper_translate( 'Source Info' ) ) . '

'; echo '
'; echo ''; echo ''; echo ''; echo '
' . esc_attr( wqhelper_translate( 'WordQuest Icon' ) ) . ' WordQuest Alliance
'; echo '→ WordQuest Plugins
'; echo '→ Plugin Directory
'; echo '
'; } } echo '
'; // --- hidden iframe for plugin actions --- echo ''; echo ''; }; } // ------------------------------- // Version Specific Plugins Column // ------------------------------- $funcname = 'wqhelper_admin_plugins_column_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function( $args ) { global $wordquesthelper, $wordquestplugins, $wqurls, $wqdebug; // --- check if WordPress.Org plugins only --- // 1.6.6: check if current WQ plugins are all installed via WordPress.Org // (if so, only provide option to install other WQ plugins in repository) global $wq_wordpress_org; $wq_wordpress_org = true; foreach ( $wordquestplugins as $pluginslug => $plugin ) { // - if this is false, it was from WordQuest not WordPress - if ( !$plugin['wporg'] ) { $wq_wordpress_org = false; } } // --- Plugin Action Select Javascript --- // 1.7.2: updated star rating link // TODO: test all options here more thoroughly..? echo ""; // --- link styles --- echo ""; // --- Get Installed and Active Plugin Slugs --- $i = 0; $pluginslugs = array(); foreach ( $wordquestplugins as $pluginslug => $values ) { $pluginslugs[$i] = $pluginslug; $i++; } // if ($wqdebug) {echo "";} // --- Get All Installed Plugins Info --- $i = 0; $installedplugins = get_plugins(); $installedslugs = array(); foreach ( $installedplugins as $pluginfile => $values ) { $installedslugs[$i] = sanitize_title( $values['Name'] ); $i++; } // if ($wqdebug) {echo "";} // if ($wqdebug) {echo "";} // Get Plugin Update Info // ---------------------- // 1.6.6: define empty pluginupdates array $i = 0; $updateplugins = get_site_transient( 'update_plugins' ); $pluginupdates = array(); // 1.7.3: adde property exists check if ( property_exists( $updateplugins, 'response' ) ) { foreach ( $updateplugins->response as $pluginfile => $values ) { $pluginupdates[$i] = $values->slug; $i++; } } // if ($wqdebug) {echo "";} // if ($wqdebug) {echo "";} // --- Get Available Plugins from WordQuest.org --- $plugininfo = wqhelper_get_plugin_info(); // process plugin info $i = 0; $wqplugins = $wqpluginslugs = array(); if ( is_array( $plugininfo ) ) { foreach ( $plugininfo as $plugin ) { // print_r( $plugin ); // debug point if ( isset( $plugin['slug'] ) ) { $wqpluginslugs[$i] = $pluginslug = $plugin['slug']; $i++; if ( isset( $plugin['title'] ) ) { $wqplugins[$pluginslug]['title'] = $plugin['title']; } if ( isset( $plugin['home'] ) ) { $wqplugins[$pluginslug]['home'] = $plugin['home']; } if ( isset( $plugin['description'] ) ) { $wqplugins[$pluginslug]['description'] = $plugin['description']; } if ( isset( $plugin['icon'] ) ) { $wqplugins[$pluginslug]['icon'] = $plugin['icon']; } if ( isset( $plugin['paidplans'] ) ) { $wqplugins[$pluginslug]['paidplans'] = $plugin['paidplans']; } if ( isset( $plugin['package'] ) ) { $wqplugins[$pluginslug]['package'] = $plugin['package']; } if ( isset( $plugin['tags'] ) ) { $wqplugins[$pluginslug]['tags'] = $plugin['tags']; } if ( isset( $plugin['cats'] ) ) { $wqplugins[$pluginslug]['cats'] = $plugin['cats']; } // 1.6.5: check release date and status if ( isset( $plugin['releasedate'] ) ) { $wqplugins[$pluginslug]['releasedate'] = $plugin['releasedate']; } if ( isset( $plugin['releasestatus'] ) ) { $wqplugins[$pluginslug]['releasestatus'] = $plugin['releasestatus']; } else { $wqplugins[$pluginslug]['releasestatus'] = 'Upcoming'; } // 1.6.6: check for wordpress.org slug if ( isset( $plugin['wporgslug'] ) ) { $wqplugins[$pluginslug]['wporgslug'] = $plugin['wporgslug']; } else { $wpplugins[$pluginslug]['wporgslug'] = false; } if ( in_array( $pluginslug, $installedslugs ) ) { $wqplugins[$pluginslug]['installed'] = 'yes'; } else { $wqplugins[$pluginslug]['installed'] = 'no'; } // --- get latest plugin release --- if ( isset( $plugin['latestrelease'] ) && ( 'yes' == $plugin['latestrelease'] ) ) { $wqplugins[$pluginslug]['latestrelease'] = 'yes'; $latestrelease = $wqplugins[$pluginslug]; $latestrelease['slug'] = $pluginslug; } // --- get next plugin release --- // 1.6.5: check for next plugin release also if ( isset( $plugin['nextrelease'] ) && ( 'yes' == $plugin['nextrelease'] ) ) { $wqplugins[$pluginslug]['nextrelease'] = 'yes'; $nextrelease = $wqplugins[$pluginslug]; $nextrelease['slug'] = $pluginslug; } } } } // if ($wqdebug) {echo "";} if ( $wqdebug ) { // phpcs:ignore WordPress.PHP.DevelopmentFunctions echo ""; } // --- maybe set Plugin Release Info --- global $wqreleases; if ( isset( $latestrelease ) ) { $wqreleases['latest'] = $latestrelease; } if ( isset( $nextrelease ) ) { $wqreleases['next'] = $nextrelease; } // --- get Installed Wordquest Plugin Data --- $plugins = $inactiveplugins = $pluginfiles = $inactiveversions = array(); $i = $j = 0; foreach ( $installedplugins as $pluginfile => $values ) { $pluginslug = sanitize_title( $values['Name'] ); $pluginfiles[$pluginslug] = $pluginfile; // echo '***'.$pluginslug.'***'; // debug point if ( in_array( $pluginslug, $wqpluginslugs ) || in_array( $pluginslug, $pluginslugs ) ) { // --- set plugin data --- $plugins[$i]['slug'] = $pluginslug; $plugins[$i]['name'] = $values['Name']; $plugins[$i]['filename'] = $pluginfile; $plugins[$i]['version'] = $values['Version']; $plugins[$i]['description'] = $values['Description']; // --- check for matching plugin update --- if ( in_array( $pluginslug, $pluginupdates ) ) { $plugins[$i]['update'] = 'yes'; } else { $plugins[$i]['update'] = 'no'; } // --- filter out to get inactive plugins --- if ( !in_array( $pluginslug, $pluginslugs ) ) { $inactiveversions[$pluginslug] = $values['Version']; $inactiveplugins[$j] = $pluginslug; $j++; } $i++; } } // if ($wqdebug) {echo "";} // if ($wqdebug) {echo "";} // --- check if BioShip Theme installed --- $themes = wp_get_themes(); $bioshipinstalled = false; foreach ( $themes as $theme ) { // 1.8.0: use public get_stylesheet method if ( 'bioship' == $theme->get_stylesheet() ) { $bioshipinstalled = true; } } // --- open plugin column --- echo '
'; // Active Plugin Panel // ------------------- $boxid = 'wordquestactive'; $boxtitle = wqhelper_translate( 'Active WordQuest Plugins' ); echo '
'; echo '

'; echo '' . esc_html( $boxtitle ) . '

'; echo '
'; foreach ( $wordquestplugins as $pluginslug => $plugin ) { // filter out theme here if ( 'bioship' != $pluginslug ) { // --- set update link --- if ( in_array( $pluginslug, $pluginupdates ) ) { $updatelink = admin_url( 'update.php' ) . '?action=upgrade-plugin&plugin=' . $pluginfiles[$pluginslug]; $updatelink = wp_nonce_url( $updatelink, 'upgrade-plugin_' . $pluginfiles[$pluginslug] ); echo ''; } // --- linked title and version --- echo ''; // --- update / settings options --- echo ''; // --- do selected action button --- echo ''; } } echo '
'; echo ''; echo esc_html( $plugin['title'] ) . ''; echo ''; echo esc_html( $plugin['version'] ); echo ''; echo ''; echo ''; echo '
'; // Inactive Plugin Panel // --------------------- if ( count( $inactiveplugins ) > 0 ) { $boxid = 'wordquestinactive'; $boxtitle = wqhelper_translate( 'Inactive WordQuest Plugins' ); echo '
'; echo '

'; echo '' . esc_html( $boxtitle ) . '

'; echo '
'; foreach ( $inactiveplugins as $inactiveplugin ) { // --- set activate link --- $activatelink = admin_url( 'plugins.php' ) . '?action=activate&plugin=' . $pluginfiles[$inactiveplugin]; $activatelink = wp_nonce_url( $activatelink, 'activate-plugin_' . $pluginfiles[$inactiveplugin] ); echo ""; // --- set update link --- if ( in_array( $inactiveplugin, $pluginupdates ) ) { $updatelink = admin_url( 'update.php' ) . '?action=upgrade-plugin&plugin=' . $pluginfiles[$inactiveplugin]; // 1.8.0: fix to incorrect plural key usage, should be singular $updatelink = wp_nonce_url( $updatelink, 'upgrade-plugin_' . $pluginfiles[$inactiveplugin] ); echo ""; } // --- linked title and version --- echo ''; // --- select plugin action --- echo ''; // --- plugin action button --- echo ''; } echo '
'; echo ''; echo esc_html( $wqplugins[$inactiveplugin]['title'] ) . ''; echo ''; echo esc_html( $inactiveversions[$inactiveplugin] ); echo ''; echo ''; echo ''; echo '
'; } $releasedplugins = $unreleasedplugins = array(); if ( count( $wqplugins ) > count( $wordquestplugins ) ) { foreach ( $wqplugins as $pluginslug => $wqplugin ) { if ( !in_array( $pluginslug, $installedslugs ) && !in_array( $pluginslug, $inactiveplugins ) ) { if ( 'Released' == $wqplugin['releasestatus'] ) { $releasedplugins[$pluginslug] = $wqplugin; } else { $releasetime = strtotime( $wqplugin['releasedate'] ); $wqplugin['slug'] = $pluginslug; $unreleasedplugins[$releasetime] = $wqplugin; } } } } // Available Plugin Panel // ---------------------- if ( count( $releasedplugins ) > 0 ) { if ( $wqdebug ) { // phpcs:ignore WordPress.PHP.DevelopmentFunctions echo ""; } $boxid = 'wordquestavailable'; $boxtitle = wqhelper_translate( 'Available WordQuest Plugins' ); echo '
'; echo '

'; echo '' . esc_html( $boxtitle ) . '

'; echo '
'; foreach ( $releasedplugins as $pluginslug => $wqplugin ) { // --- set install plugin link --- // 1.6.5: add separate install link URL for each plugin for nonce checking // 1.6.6: use wordpress.org link if all plugins are from wordpress.org if ( $wq_wordpress_org && $wqplugin['wporgslug'] ) { $installlink = self_admin_url( 'update.php' ) . '?action=install-plugin&plugin=' . $wqplugin['wporgslug']; $installlink = wp_nonce_url( $installlink, 'install-plugin_' . $wqplugin['wporgslug'] ); echo ''; } elseif ( !$wq_wordpress_org && is_array( $wqplugin['package'] ) ) { $installlink = admin_url( 'update.php' ) . '?action=wordquest_plugin_install&plugin=' . $pluginslug; $installlink = wp_nonce_url( $installlink, 'plugin-upload' ); echo ''; } // --- linked plugin title --- echo ''; // echo ''; // --- plugin action select --- echo '"; // --- plugin action button --- echo ''; } echo '
'; echo ''; echo esc_html( $wqplugin['title'] ) . ''; echo '' . esc_html( $wqplugin['version'] ) . ''; echo ''; echo ''; echo '
'; } // Upcoming Plugin Panel // --------------------- if ( count( $unreleasedplugins ) > 0 ) { ksort( $unreleasedplugins ); if ( $wqdebug ) { // phpcs:ignore WordPress.PHP.DevelopmentFunctions echo ""; } $boxid = 'wordquestupcoming'; $boxtitle = wqhelper_translate( 'Upcoming WordQuest Plugins' ); echo '
'; echo '

'; echo '' . esc_html( $boxtitle ) . '

'; echo '
'; foreach ( $unreleasedplugins as $releasetime => $wqplugin ) { // $pluginslug = $wqplugin['slug']; echo ''; } echo '
'; echo ''; echo esc_html( $wqplugin['title'] ) . ''; echo ''; echo ''; echo esc_html( wqhelper_translate( 'Expected' ) ) . ': ' . esc_html( date( 'jS F Y', $releasetime ) ); echo ''; echo '
'; } // BioShip Theme Panel // ------------------- $boxid = 'bioship'; $boxtitle = wqhelper_translate( 'BioShip Theme Framework' ); echo '
'; echo '

'; echo '' . esc_html( $boxtitle ) . '

'; echo '
'; echo '
'; if ( $bioshipinstalled ) { // --- check if BioShip Theme is active --- $theme = wp_get_theme(); // 1.8.0: use public get_stylesheet method if ( 'bioship' == $theme->get_stylesheet() ) { echo esc_html( wqhelper_translate( 'Sweet! You are using' ) ) . ' '; echo esc_html( wqhelper_translate( 'BioShip Theme Framework' ) ) . '.
'; echo esc_html( wqhelper_translate( 'Great choice!' ) ) . ' '; // 1.6.7: added BioShip Theme Options link here if ( THEMETITAN ) { $optionsurl = admin_url( 'admin.php' ) . '?page=bioship-options'; } elseif ( THEMEOPT ) { $optionsurl = admin_url( 'admin.php' ) . '?page=options-framework'; } else { $optionsurl = admin_url( 'customize.php' ); } echo '' . esc_html( wqhelper_translate( 'Theme Options' ) ) . ''; } elseif ( is_child_theme() && ( 'bioship' == $theme->get_template() ) ) { // 1.8.0: use public get_template method echo esc_html( wqhelper_translate( 'Groovy. You are using' ) ) . ' '; echo esc_html( wqhelper_translate( 'BioShip Framework' ) ) . '!
'; echo esc_html( wqhelper_translate( 'Your Child Theme is' ) ) . ' ' . esc_html( $theme->Name ) . '

'; // 1.6.7: add Child Theme Options link here if ( THEMETITAN ) { $optionsurl = admin_url( 'admin.php' ) . '?page=bioship-options'; } elseif ( THEMEOPT ) { $optionsurl = admin_url( 'admin.php' ) . '?page=options-framework'; } else { $optionsurl = admin_url( 'customize.php' ); } echo '' . esc_html( wqhelper_translate( 'Theme Options' ) ) . ''; } else { echo esc_html( wqhelper_translate( 'Looks like you have BioShip installed!' ) ) . '
'; echo '...' . esc_html( wqhelper_translate( 'but it is not yet your active theme.' ) ) . '

'; // --- BioShip Theme activation link --- $activatelink = admin_url( 'themes.php' ) . '?action=activate&stylesheet=bioship'; $activatelink = wp_nonce_url( $activatelink, 'switch-theme_bioship' ); echo '' . esc_html( wqhelper_translate( 'Click here to activate it now' ) ) . '.

'; // --- Check for Theme Test Drive --- echo '
'; if ( function_exists( 'themedrive_determine_theme' ) ) { // TODO: a better check here? this actually makes no sense // ...as should be using an options page redirect link instead if ( class_exists( 'TitanFramework' ) ) { $testdrivelink = admin_url( 'admin.php' ) . '?page=bioship-options&theme=bioship'; } elseif ( function_exists( 'OptionsFramework_Init' ) ) { $testdrivelink = admin_url( 'themes.php' ) . '?page=options-framework&theme=bioship'; } else { $testdrivelink = admin_url( 'customize.php' ) . '?theme=bioship'; } echo esc_html( wqhelper_translate( 'or' ) ) . ', '; echo esc_html( wqhelper_translate( 'take it for a Theme Test Drive' ) ) . '.'; } elseif ( in_array( 'theme-test-drive', $installedplugins ) ) { // --- Theme Test Drive plugin activation link --- $activatelink = admin_url( 'plugins.php' ) . '?action=activate&plugin=' . rawurlencode( 'theme-test-drive/themedrive.php' ); $activatelink = wp_nonce_url( $activatelink, 'activate-plugin_theme-test-drive/themedrive.php' ); echo esc_html( wqhelper_translate( 'or' ) ) . ', '; echo esc_html( wqhelper_translate( 'activate Theme Test Drive plugin' ) ) . '
'; echo esc_html( wqhelper_translate( 'to test BioShip without affecting your current site.' ) ); } else { // --- Theme Test Drive plugin installation link --- $installlink = admin_url( 'update.php' ) . '?action=install-plugin&plugin=theme-test-drive'; $installlink = wp_nonce_url( $installlink, 'install-plugin' ); echo esc_html( wqhelper_translate( 'or' ) ) . ', '; echo esc_html( wqhelper_translate( 'install Theme Test Drive plugin' ) ) . '
'; echo esc_html( wqhelper_translate( 'to test BioShip without affecting your current site.' ) ); } echo '
'; } } else { // --- BioShip not installed, just provide a link --- echo esc_html( wqhelper_translate( 'Also from' ) ) . ' WordQuest Alliance, ' . esc_html( wqhelper_translate( 'check out the' ) ) . '
'; echo 'BioShip Theme Framework
'; echo esc_html( wqhelper_translate( 'A highly flexible and responsive starter theme' ) ) . '
'; echo esc_html( wqhelper_translate( 'for users, designers and developers.' ) ); } // 1.8.0: added missing bioship installed check if ( $bioshipinstalled && isset( $theme ) && is_object( $theme ) ) { if ( ( 'bioship' == $theme->get_template() ) || ( 'bioship' == $theme->get_stylesheet() ) ) { // 1.8.0: use public get_template and get_stylesheet methods // 1.7.3: addded missing function prefix if ( function_exists( 'bioship_admin_theme_updates_available' ) ) { $themeupdates = bioship_admin_theme_updates_available(); if ( '' != $themeupdates ) { echo '
'; echo wp_kses_post( $themeupdates ); echo '

'; } } // TODO: future link for rating BioShip on wordpress.org theme repository ? // $ratelink = 'https://wordpress.org/support/theme/bioship/reviews/#new-post'; // echo '
' . esc_html( wqhelper_translate( 'Rate BioShip on WordPress.Org' ) ) . '
'; } } // BioShip Feed // ------------ // (only displays if Bioship theme is active) // 1.7.3: added missing bioship function prefix if ( function_exists( 'bioship_muscle_bioship_dashboard_feed_widget' ) ) { // $boxid = 'bioshipfeed'; $boxtitle = wphelper_translate('BioShip News'); // echo '
'; // echo '

'.$boxtitle.'

'; // echo '
'; bioship_muscle_bioship_dashboard_feed_widget( false ); // echo '
'; } echo '
'; echo '
'; // --- end column --- echo '
'; }; } // ---------------------------- // Version Specific Feed Column // ---------------------------- $funcname = 'wqhelper_admin_feeds_column_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function( $args ) { // 1.8.0: set missing global global $wqurls; // --- open feeds column --- echo '
'; // Latest / Next Release // --------------------- global $wqreleases; $latestrelease = $nextrelease = ''; if ( isset( $wqreleases['latest'] ) ) { $latestrelease = $wqreleases['latest']; } if ( isset( $wqreleases['next'] ) ) { $nextrelease = $wqreleases['next']; } if ( isset( $latestrelease ) && is_array( $latestrelease ) ) { if ( 'no' == $latestrelease['installed'] ) { $release = $latestrelease; $boxid = 'wordquestlatest'; $boxtitle = wqhelper_translate( 'Latest Release' ); } else { $release = $nextrelease; $boxid = 'wordquestupcoming'; $boxtitle = wqhelper_translate( 'Upcoming Release' ); } } elseif ( isset( $nextrelease ) && is_array( $nextrelease ) ) { $release = $nextrelease; $boxid = 'wordquestupcoming'; $boxtitle = wqhelper_translate( 'Upcoming Release' ); } if ( isset( $release ) && is_array( $release ) ) { echo '
'; echo '

'; echo '' . esc_html( $boxtitle ) . '

'; echo '
'; echo '
'; echo '' . esc_attr( wqhelper_translate( 'Latest Release Icon' ) ) . '
'; echo '' . esc_html( $release['title'] ) . ''; echo '
'; echo '' . esc_html( $release['description'] ) . '

'; if ( isset( $release['package'] ) && is_array( $release['package'] ) ) { // 1.6.6: check for wordpress.org only installs global $wq_wordpress_org; $installlink = false; if ( $wq_wordpress_org && $release['wporgslug'] ) { $installlink = self_admin_url( 'update.php' ) . '?action=install-plugin&plugin=' . $release['wporgslug']; $installlink = wp_nonce_url( $installlink, 'install-plugin_' . $release['wporgslug'] ); } else { $installlink = admin_url( 'update.php' ) . '?action=wordquest_plugin_install&plugin=' . $release['slug']; $installlink = wp_nonce_url( $installlink, 'plugin-upload' ); } if ( $installlink ) { echo ''; echo '
' . esc_html( wqhelper_translate( 'Install Now' ) ) . '
'; } else { $pluginlink = $wqurls['wq'] . '/plugins/' . $release['slug']; echo '
→ ' . esc_html( wqhelper_translate( 'Plugin Home' ) ) . '
'; } } else { echo '
' . esc_html( wqhelper_translate( 'Expected' ) ) . ': ' . esc_html( date( 'jS F Y', strtotime( $release['releasedate'] ) ) ); } echo '
'; echo '
'; } // WordQuest Feed // -------------- $boxid = 'wordquestfeed'; $boxtitle = wqhelper_translate( 'WordQuest News' ); if ( function_exists( 'wqhelper_dashboard_feed_widget' ) ) { echo '
'; echo '

'; echo '' . esc_html( $boxtitle ) . '

'; echo '
'; wqhelper_dashboard_feed_widget(); echo '
'; } // Editors Picks // ------------- $boxid = 'recommendations'; $boxtitle = wqhelper_translate( 'Editor Picks' ); // TODO: Recommended Plugins via Plugin Review? // echo '
'; // echo '

'.$boxtitle.'

'; // echo '
'; // echo "Recommended Plugins..."; // print_r($recommended); // echo '
'; // PluginReview Feed // ----------------- $boxid = 'pluginreviewfeed'; $boxtitle = wqhelper_translate( 'Plugin Reviews' ); if ( function_exists( 'wqhelper_pluginreview_feed_widget' ) ) { echo '
'; echo '

'; echo '' . esc_html( $boxtitle ) . '

'; echo '
'; wqhelper_pluginreview_feed_widget(); echo '
'; } // --- close column --- echo '
'; // --- enqueue feed javascript --- if ( !has_action( 'admin_footer', 'wqhelper_dashboard_feed_javascript' ) ) { add_action( 'admin_footer', 'wqhelper_dashboard_feed_javascript' ); } }; } // ----------------------------- // Version Specific Admin Styles // ----------------------------- $funcname = 'wqhelper_admin_styles_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function() { // --- hide Wordquest plugin freemius submenu items if top level admin menu not open --- echo ""; }; } // ----------------------------- // Version Specific Admin Script // ----------------------------- $funcname = 'wqhelper_admin_scripts_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function() { // --- wordquest admin submenu icon and styling fixes --- // 1.7.9: change margin-left to padding-left on link // 1.7.9: added margin left and top to icon // 1.8.0: fix insertBefore(this) to insertBefore(jQuery(this)) echo ""; }; } // -------------------------- // Install a WordQuest Plugin // -------------------------- // 1.6.5: hook to update.php update-custom_{ACTION} where ACTION = 'wordquest_plugin_install' add_action( 'update-custom_wordquest_plugin_install', 'wqhelper_install_plugin' ); $funcname = 'wqhelper_install_plugin_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function() { global $wqurls; // --- check permissions and nonce --- if ( !current_user_can( 'upload_plugins' ) ) { wp_die( esc_html( wqhelper_translate( 'Sorry, you are not allowed to install plugins on this site.' ) ) ); } check_admin_referer( 'plugin-upload' ); // --- get the package info from download server --- if ( !isset( $_REQUEST['plugin'] ) ) { wp_die( esc_html( wqhelper_translate( 'Error: No Plugin specified.' ) ) ); } // 1.5.9: sanitize plugin slug // 1.8.1: combined sanitize_title on same line $pluginslug = sanitize_title( $_REQUEST['plugin'] ); if ( '' == $pluginslug ) { wp_die( esc_html( wqhelper_translate( 'Error: Invalid Plugin slug specified.' ) ) ); } // --- get the plugin package data --- $url = $wqurls['wq'] . '/downloads/?action=get_metadata&slug=' . $pluginslug; $response = wp_remote_get( $url, array( 'timeout' => 30 ) ); if ( !is_wp_error( $response ) ) { if ( '404' == $response['response']['code'] ) { // --- on failure try to get package info from stored transient data --- $plugininfo = get_transient( 'wordquest_plugin_info' ); // 1.8.0: fix to variable typo pluginfo if ( is_array( $plugininfo ) ) { foreach ( $plugininfo as $plugin ) { if ( $plugin['slug'] == $pluginslug ) { $pluginpackage = $plugin['package']; } } } } else { $pluginpackage = json_decode( $response['body'], true ); } } if ( !isset( $pluginpackage ) ) { $protocol = is_ssl() ? 'https://' : 'http://'; // 1.8.2: add sanitize_text_field to $_SERVER['HTTP_HOST'] $tryagainurl = $protocol . sanitize_text_field( $_SERVER['HTTP_HOST'] ) . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']; $message = esc_html( wqhelper_translate( 'Failed to retrieve download package information.' ) ); $message .= ' '; $message .= esc_html( wqhelper_translate( 'Click here to try again.' ) ) . ''; // 1.8.1: use wp_kses_post on message wp_die( wp_kses_post( $message ) ); } // 1.6.5: pass the package download URL to WordPress to do the rest // --- set the Plugin_Installer_Skin arguments --- $url = $pluginpackage['download_url']; $title = sprintf( wqhelper_translate( 'Installing Plugin from URL: %s' ), esc_html( $url ) ); $nonce = 'plugin-upload'; $type = 'web'; // 1.8.0: disuse compact function // $args = compact( 'type', 'title', 'nonce', 'url' ); $args = array( 'type' => 'web', 'title' => $title, 'nonce' => 'plugin-upload', 'url' => $url, ); // --- custom Plugin_Upgrader (via /wp-admin/upgrade.php) --- // 1.8.0: fix to function typo wqhelper_translate $title = wqhelper_translate( 'Upload Plugin' ); $parent_file = 'plugins.php'; $submenu_file = 'plugin-install.php'; require_once ABSPATH . 'wp-admin/admin-header.php'; $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( $args ) ); $result = $upgrader->install( $url ); include ABSPATH . 'wp-admin/admin-footer.php'; }; } // ------------------------ // === Sidebar FloatBox === // ------------------------ // ---------------------- // Main Floatbox Function // ---------------------- $funcname = 'wqhelper_sidebar_floatbox_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function( $args ) { global $wqdebug, $wqurls; if ( $wqdebug ) { // phpcs:ignore WordPress.PHP.DevelopmentFunctions echo ""; } if ( count( $args ) == 7 ) { // --- the old way, sending all args individually --- $prefix = $args[0]; $pluginslug = $slug = $args[1]; $freepremium = $args[2]; $wporgslug = $args[3]; $savebutton = $args[4]; $plugintitle = $args[5]; $pluginversion = $args[6]; } else { // --- the new way, just sending two args --- $pluginslug = $slug = $args[0]; $savebutton = $args[1]; // --- get the other args using the slug and global array --- global $wordquestplugins; $pluginversion = $wordquestplugins[$slug]['version']; $plugintitle = $wordquestplugins[$slug]['title']; $prefix = $wordquestplugins[$slug]['settings']; // 1.7.7: added isset check for plan key for back-compat if ( isset( $wordquestplugins[$slug]['plan'] ) ) { $freepremium = $wordquestplugins[$slug]['plan']; } else { $freepremium = 'free'; } $wporg = $wordquestplugins[$slug]['wporg']; if ( isset( $wordquestplugins[$slug]['wporgslug'] ) ) { $wporgslug = $wordquestplugins[$slug]['wporgslug']; } else { $wporgslug = ''; } // --- get donate link --- // 1.7.4: get donate link and set author // 1.7.6: fix to check if donate key is defined $author = 'wordquest'; if ( isset( $wordquestplugins[$slug]['donate'] ) ) { $donatelink = $wordquestplugins[$slug]['donate']; if ( strstr( $donatelink, 'wpmedic' ) ) { $author = 'wpmedic'; } } if ( $wqdebug ) { echo ""; } } // --- set which boxes to show --- $boxes = array( 'donate', 'subscribe', 'recommend' ); // 'report', 'testimonials' $boxes = apply_filters( $prefix . '_display_sidebar_boxes', $boxes ); if ( $wqdebug ) { // phpcs:ignore WordPress.PHP.DevelopmentFunctions echo ""; } // 1.5.0: get/convert to single array of plugin sidebar options // 1.6.0: fix to sidebar options variable $sidebaroptions = get_option( $prefix . '_sidebar_options' ); if ( !$sidebaroptions || ( '' == $sidebaroptions ) || !is_array( $sidebaroptions ) ) { $sidebaroptions = array( 'installdate' => date( 'Y-m-d' ), 'adsboxoff' => get_option( $prefix . '_ads_box_off' ), 'donationboxoff' => get_option( $prefix . '_donation_box_off' ), 'reportboxoff' => get_option( $prefix . '_report_box_off' ), 'subscribeboxoff' => '', // 'testimonialboxoff' => '', ); delete_option( $prefix . '_ads_box_off' ); delete_option( $prefix . '_donation_box_off' ); delete_option( $prefix . '_report_box_off' ); update_option( $prefix . '_sidebar_options', $sidebaroptions ); } // 1.6.9: fix to possible undefined keys $changed = false; if ( !isset( $sidebaroptions['installdate'] ) ) { $sidebaroptions['installdate'] = date( 'Y-m-d' ); $changed = true; } if ( !isset( $sidebaroptions['donationboxoff'] ) ) { $sidebaroptions['donationboxoff'] = ''; $changed = true; } if ( !isset( $sidebaroptions['subscribeboxoff'] ) ) { $sidebaroptions['subscribeboxoff'] = ''; $changed = true; } // if ( !isset( $sidebaroptions['testimonialboxoff' ) ) { // $sidebaroptions['testimonialboxoff'] = ''; // $changed = true; // } if ( !isset( $sidebaroptions['reportboxoff'] ) ) { $sidebaroptions['reportboxoff'] = ''; $changed = true; } if ( !isset( $sidebaroptions['adsboxoff'] ) ) { $sidebaroptions['adsboxoff'] = ''; $changed = true; } update_option( $prefix, '_sidebar_options', $sidebaroptions ); // --- sidebar scripts --- // 1.7.8: fix to sticky kit recalc function check (sticky_in_parent) echo ""; // --- Sidebar Floatbox Styles --- echo ''; // --- open sidebar div -- echo '
'; if ( $wqdebug ) { echo ''; } // --- call (optional) Plugin Sidebar Header --- $funcname = $prefix . '_sidebar_plugin_header'; if ( function_exists( $funcname ) ) { call_user_func( $funcname ); } // Save Settings Button // -------------------- if ( 'replace' != $savebutton ) { echo '
'; echo '

' . esc_html( wqhelper_translate( 'Update Settings' ) ) . '

'; echo '
'; $savebuttontrigger = $sidebaroptionsbutton = false; if ( 'yes' == $savebutton ) { $savebuttontrigger = $sidebaroptionsbutton = true; // --- set button output --- // 1.8.1: remove onclick attributes from buttons to script $button = ''; $button .= ''; $button .= '
'; $button .= ''; $button .= ''; $button .= ''; $button .= '
'; $button = apply_filters( 'wordquest_sidebar_save_button', $button, $pluginslug ); // 1.8.1: use wp_kses_post on button echo wp_kses_post( $button ); } elseif ( 'no' == $savebutton ) { echo ''; } else { // --- show sidebar save options only --- $sidebaroptionsbutton = true; echo ''; } if ( $savebuttontrigger || $sidebaroptionsbutton ) { // 1.8.1: output script function directly // echo ""; echo ""; } // --- sidebar settings box --- echo '
'; echo '
'; } // Donation Box // ------------ // 1.7.8: check if donation box is on $args = array( $prefix, $pluginslug ); if ( in_array( 'donate', $boxes ) ) { // --- open donate box --- echo ''; } // Subscriber Form Box // ------------------- // 1.7.8: added subscriber form box if ( in_array( 'subscribe', $boxes ) ) { // --- open donate box --- echo ''; } // Testimonials Form Box // --------------------- if ( in_array( 'testimonial', $boxes ) ) { // --- open donate box --- echo ''; } // Bonus Report Subscription Form // ------------------------------ // 1.7.2: allow for bonus offer box override if ( in_array( 'report', $boxes ) ) { echo ''; } // PluginReview.Net Plugin Recommendations // --------------------------------------- if ( in_array( 'recommend', $boxes ) ) { echo ''; } // Call Plugin Footer Function // --------------------------- $funcname = $prefix . '_sidebar_plugin_footer'; echo '
'; if ( function_exists( $funcname ) ) { call_user_func( $funcname ); } else { // Default Sidebar Plugin Footer // ----------------------------- // 1.7.4: link display depending on author $wqanchor = wqhelper_translate( 'WordQuest Plugins' ); $wpmanchor = wqhelper_translate( 'WP Medic Tools' ); if ( 'wordquest' == $author ) { $authordisplay = 'WordQuest Alliance'; $authorurl = $wqurls['wq']; $wqanchor = wqhelper_translate( 'More WordQuest Plugins' ); $pluginurl = $wqurls['wq'] . '/plugins/' . $pluginslug . '/'; } elseif ( 'wpmedic' == $author ) { $authordisplay = 'WP Medic'; $authorurl = $wqurls['wpm']; $wpmanchor = wqhelper_translate( 'More WP Medic Tools' ); $pluginurl = $wqurls['wpm'] . '/' . $pluginslug . '/'; } // $wqlink = '→ ' . esc_html( $wqanchor ) . '
'; // $wpmlink = '→ ' . esc_html( $wpmanchor ) . '
'; // --- set values for theme or plugin --- $footertitle = wqhelper_translate( 'Plugin Info' ); $bioanchor = wqhelper_translate( 'BioShip Framework' ); if ( 'bioship' == $pluginslug ) { // $iconurl = get_template_directory_uri() . '/images/' . $author . '.png'; $pluginurl = $wqurls['bio']; $footertitle = wqhelper_translate( 'Theme Info' ); } // else { // $iconurl = plugins_url( 'images/' . $author . '.png', __FILE__ ); // } // --- output plugin footer --- echo '
'; echo '

' . esc_html( $footertitle ) . '

'; // echo ''; // echo '
'; // echo ''; // echo ''; echo '
'; echo '' . esc_html( $plugintitle ) . '   v' . esc_html( $pluginversion ) . '
'; echo esc_html( wqhelper_translate( 'by' ) ) . ' ' . esc_html( $authordisplay ) . '

'; // 1.8.1: output links direct instead of storing if ( 'wpmedic' == $author ) { echo '→ ' . esc_html( $wpmanchor ) . '
'; echo '→ ' . esc_html( $wqanchor ) . '
'; } else { echo '→ ' . esc_html( $wqanchor ) . '
'; echo '→ ' . esc_html( $wpmanchor ) . '
'; } if ( 'bioship' != $pluginslug ) { echo '→ ' . esc_html( $bioanchor ) . '
'; } echo '→ ' . esc_html( wqhelper_translate( 'Sorted Plugin Directory' ) ) . ''; echo '
'; // echo '
'; echo '
'; } echo '
'; // --- close sidebar float div --- echo '
'; }; } // ------------------------ // Patreon Supporter Button // ------------------------ // 1.7.4: added Patreon Supporter Button $funcname = 'wqhelper_sidebar_patreon_button_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function( $args ) { global $wordquestplugins; $prefix = $args[0]; $pluginslug = $args[1]; $settings = $wordquestplugins[$pluginslug]; $donatelink = apply_filters( 'wqhelper_donate_link', $settings['donate'], $pluginslug ); $message = apply_filters( 'wqhelper_donate_message', $settings['donatetext'], $pluginslug ); // --- set button image URL --- if ( 'bioship' == $pluginslug ) { $imageurl = get_template_directory_uri() . '/images/patreon-button.jpg'; } else { // 1.7.5: check/fix for Patreon button URL (cross-versions) if ( file_exists( dirname( __FILE__ ) . '/images/patreon-button.jpg' ) ) { $imageurl = plugins_url( 'images/patreon-button.jpg', __FILE__ ); } else { // --- try to reliably get actual plugin path/URL --- $realslug = sanitize_title( $wordquestplugins[$pluginslug]['title'] ); if ( file_exists( WP_PLUGIN_DIR . '/' . $realslug . '/images/patreon-button.jpg' ) ) { $imageurl = WP_PLUGIN_URL . '/' . $realslug . '/images/patreon-button.jpg'; } } } $imageurl = apply_filters( 'wqhelper_donate_image', $imageurl, $pluginslug ); // --- output Patreon button --- echo '
' . esc_html( $message ) . '
'; echo ''; if ( $imageurl ) { echo ''; } else { echo esc_html( wqhelper_translate( 'Become a Patron' ) ); } echo '
'; // --- image hover styling --- echo ''; }; } // ---------------- // Paypal Donations // ---------------- $funcname = 'wqhelper_sidebar_paypal_donations_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function( $args ) { global $wqurls; $prefix = $args[0]; $pluginslug = $args[1]; // --- make display name from the plugin slug --- if ( strstr( $pluginslug, '-' ) ) { $parts = explode( '-', $pluginslug ); $i = 0; foreach ( $parts as $part ) { if ( 'wp' == $part ) { $parts[$i] = 'WP'; } else { $parts[$i] = strtoupper( substr( $part, 0, 1 ) ) . substr( $part, 1, ( strlen( $part ) - 1 ) ); } $i++; } $pluginname = implode( ' ', $parts ); } else { $pluginname = strtoupper( substr( $pluginslug, 0, 1 ) ) . substr( $pluginslug, 1, ( strlen( $pluginslug ) - 1 ) ); } // --- donations scripts --- echo ""; // --- set Paypal notification URL --- $notifyurl = $wqurls['wq'] . '/?estore_pp_ipn=process'; $sandbox = ''; // $sandbox = 'sandbox.'; // --- recurring / one-time switcher --- echo '
'; echo ''; echo ' ' . esc_html( wqhelper_translate( 'Supporter' ) ) . ' '; echo ''; echo ' '; echo '' . esc_html( wqhelper_translate( 'One Time' ) ) . ''; echo '
'; // --- set weekly amount options --- // 1.5.0: added weekly amounts echo '
'; echo ''; echo '
'; // --- set monthly amount options --- // 1.5.0: added monthly amounts echo '
'; echo ''; echo '
'; // note: eStore recurring subscription form // $wqurls['wq'].'/?wp_eStore_subscribe=LEVEL&c_input='.$pluginslug; // --- set donate image URL --- if ( 'bioship' == $pluginslug ) { $donateimage = get_template_directory_uri() . '/images/pp-donate.jpg'; } else { $donateimage = plugins_url( '/images/pp-donate.jpg', __FILE__ ); } // --- recurring donation form --- echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; /// --- one time donation form --- // $wqurls['wq'].'/?wp_eStore_donation=23&var1_price=AMOUNT&c_input='.$pluginslug; echo '
'; }; } // --------------- // Testimonial Box // --------------- $funcname = 'wqhelper_sidebar_testimonial_box_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function( $args ) { global $wqurls, $current_user; $current_user = wp_get_current_user(); $useremail = $current_user->user_email; if ( strstr( $useremail, '@localhost' ) ) { $useremail = ''; } $userid = $current_user->ID; $userdata = get_userdata( $userid ); $username = $userdata->first_name; $lastname = $userdata->last_name; if ( '' != $lastname ) { $username .= ' ' . $lastname; } $prefix = $args[0]; $pluginslug = $args[1]; $pluginslug = str_replace( '-', '', $pluginslug ); // --- testimonial script --- echo ""; // --- testimonial form --- echo '
' . esc_html( wqhelper_translate( 'Send me a thank you or testimonial.' ) ) . '
'; echo ''; echo ''; }; } // --------------------- // Save Sidebar Settings // --------------------- // !! caller exception !! uses form matching version function $funcname = 'wqhelper_update_sidebar_options_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function() { // 1.7.8: fix sidebar option saveing variable pre to prefix // 1.8.1: use sanitize_title on request variable // phpcs:ignore WordPress.Security.NonceVerification.Recommended $prefix = sanitize_title( $_REQUEST['sidebarprefix'] ); if ( current_user_can( 'manage_options' ) ) { // 1.6.5: check nonce field check_admin_referer( $prefix . '_sidebar' ); // 1.5.0: convert to single array of plugin sidebar options $sidebaroptions = get_option( $prefix . '_sidebar_options' ); if ( !$sidebaroptions ) { $sidebaroptions = array( 'installdate' => date( 'Y-m-d' ), ); } $sidebaroptions['adsboxoff'] = $sidebaroptions['subscribeboxoff'] = $sidebaroptions['donationboxoff'] = $sidebaroptions['reportboxoff'] = ''; // 1.8.0: reduce code by looping box options $options = array( '_donation_box_off' => 'donationboxoff', // '_testimonial_box_off' => 'testimonialboxoff', '_subscribe_box_off' => 'subscribeboxoff', '_report_box_off' => 'reportboxoff', '_ads_box_off' => 'adsboxoff', ); foreach ( $options as $key => $option ) { // phpcs:ignore WordPress.Security.NonceValidation.Recommended if ( isset( $_POST[$prefix . $key] ) && ( 'checked' == sanitize_title( $_POST[$prefix . $key] ) ) ) { $sidebaroptions[$option] = 'checked'; } } update_option( $prefix . '_sidebar_options', $sidebaroptions ); // print_r($sidebaroptions); // debug point // --- javascript response callbacks --- // 1.8.0: reduce code by looping box options $boxes = array( 'donationboxoff' => 'donate-box', 'subscribeboxoff' => 'subscribe-box', 'reportboxoff' => 'report-box', 'adsboxoff' => 'recommend-box', ); echo ""; // --- maybe call Special Update Options --- $funcname = $prefix . '_update_sidebar_options_special'; if ( function_exists( $funcname ) ) { call_user_func( $funcname ); } } exit; }; } // --------------------- // Sticky Kit Javascript // --------------------- // 1.8.1: added echo argument to function $funcname = 'wqhelper_sidebar_stickykitscript_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function( $echo = false ) { // 1.8.1: added for backwards compatibility if ( !$echo ) { ob_start(); } echo ''; // 1.8.1 added for backwards compatibility if ( !$echo ) { $stickykit = ob_get_contents(); ob_end_clean(); return $stickykit; } }; } // ' // --------------------- // Float Menu Javascript // --------------------- // 1.8.1: added echo argument to function $funcname = 'wqhelper_sidebar_floatmenuscript_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function( $echo = false ) { // 1.8.1: added for backwards compatibility if ( !$echo ) { ob_start(); } echo " "; // 1.8.1: added for backwards compatibility if ( !$echo ) { $floatbox = ob_get_contents(); ob_end_clean(); return $floatbox; } }; } // ----------------------------- // === Dashboard Feed Widget === // ----------------------------- // ----------------------------- // Add the Dashboard Feed Widget // ----------------------------- // 1.7.8: simplify dashboard detection $requesturi = $_SERVER['REQUEST_URI']; if ( ( preg_match( '|index.php|i', $requesturi ) ) || ( stristr( $requesturi, '/wp-admin/' ) ) || ( stristr( $requesturi, '/wp-admin/network/' ) ) ) { if ( !has_action( 'wp_dashboard_setup', 'wqhelper_add_dashboard_feed_widget' ) ) { add_action( 'wp_dashboard_setup', 'wqhelper_add_dashboard_feed_widget' ); } } // ------------------------ // Load the Dashboard Feeds // ------------------------ $funcname = 'wqhelper_add_dashboard_feed_widget_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function() { global $wp_meta_boxes, $current_user; if ( current_user_can( 'manage_options' ) || current_user_can( 'install_plugins' ) ) { // --- check if already loaded --- // 1.6.1: fix to undefined index warning $wordquestloaded = $pluginreviewloaded = false; foreach ( array_keys( $wp_meta_boxes['dashboard']['normal']['core'] ) as $name ) { if ( 'wordquest' == $name ) { $wordquestloaded = true; } if ( 'pluginreview' == $name ) { $pluginreviewloaded = true; } } // --- maybe add wordquest feed widget if ( !$wordquestloaded ) { wp_add_dashboard_widget( 'wordquest', 'WordQuest Alliance', 'wqhelper_dashboard_feed_widget' ); } // --- maybe add plugin review feed widget --- if ( !$pluginreviewloaded ) { wp_add_dashboard_widget( 'pluginreview', 'Plugin Review Network', 'wqhelper_pluginreview_feed_widget' ); } // --- enqueue dashboard feed javascript --- if ( !has_action( 'admin_footer', 'wqhelper_dashboard_feed_javascript' ) ) { add_action( 'admin_footer', 'wqhelper_dashboard_feed_javascript' ); } } }; } // ----------------------------------- // WordQuest Dashboard Feed Javascript // ----------------------------------- $funcname = 'wqhelper_dashboard_feed_javascript_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function() { // 1.8.0: added get admin AJAX URL $adminajax = admin_url( 'admin-ajax.php' ); // 1.8.0: removed siteurl from function for security echo ""; echo ''; }; } // ------------------------------- // WordQuest Dashboard Feed Widget // ------------------------------- $funcname = 'wqhelper_dashboard_feed_widget_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function() { // maybe Get Latest Release info // ----------------------------- global $wqdebug, $wqreleases, $wqurls; $latestrelease = $nextrelease = ''; if ( isset( $wqreleases ) ) { if ( isset( $wqreleases['latest'] ) ) { $latestrelease = $wqreleases['latest']; } if ( isset( $wqreleases['next'] ) ) { $nextrelease = $wqreleases['next']; } } else { $pluginsinfo = wqhelper_get_plugin_info(); if ( is_array( $pluginsinfo ) ) { foreach ( $pluginsinfo as $plugin ) { if ( isset( $plugin['slug'] ) ) { if ( ( isset( $plugin['latestrelease'] ) && ( 'yes' == $plugin['latestrelease'] ) ) || ( isset( $plugin['nextrelease'] ) && ( 'yes' == $plugin['nextrelease'] ) ) ) { $plugininfo = $plugin; $plugins = get_plugins(); $plugininfo['installed'] = 'no'; foreach ( $plugins as $pluginfile => $values ) { if ( sanitize_title( $values['Name'] ) == $plugininfo['slug'] ) { $plugininfo['installed'] = 'yes'; } } } if ( isset( $plugin['latestrelease'] ) && ( 'yes' == $plugin['latestrelease'] ) ) { $latestrelease = $plugininfo; } if ( isset( $plugin['nextrelease'] ) && ( 'yes' == $plugin['nextrelease'] ) ) { $nextrelease = $plugininfo; } } } } } // echo ""; // echo ""; // maybe Display Latest Release Info // --------------------------------- // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( isset( $_REQUEST['page'] ) && ( 'wordquest' == sanitize_title( $_REQUEST['page'] ) ) ) { // --- do not duplicate here as already output for wordquest page --- echo ''; } elseif ( isset( $latestrelease ) && is_array( $latestrelease ) && ( 'no' == $latestrelease['installed'] ) ) { echo '' . esc_html( wqhelper_translate( 'Latest Plugin Release' ) ) . '
'; echo '
'; echo '' . esc_attr( wqhelper_translate( 'Latest Release Icon' ) ) . '
'; echo '' . esc_html( $latestrelease['title'] ) . ''; echo '
'; echo '' . esc_html( $latestrelease['description'] ) . '

'; if ( isset( $latestrelease['package'] ) && is_array( $latestrelease['package'] ) ) { // 1.6.6: check for wordpress.org only installs global $wq_wordpress_org; $installlink = false; // 1.8.0: fix to variable typo (wqplugin) if ( $wq_wordpress_org && $latestrelease['wporgslug'] ) { $installlink = self_admin_url( 'update.php' ) . '?action=install-plugin&plugin=' . $latestrelease['wporgslug']; $installlink = wp_nonce_url( $installlink, 'install-plugin_' . $latestrelease['wporgslug'] ); } else { // 1.8.0: fix to missing left hand side variable installlink $installlink = admin_url( 'update.php' ) . '?action=wordquest_plugin_install&plugin=' . $latestrelease['slug']; $installlink = wp_nonce_url( $installlink, 'plugin-upload' ); } if ( $installlink ) { echo ''; echo '
' . esc_html( wqhelper_translate( 'Install Now' ) ) . '
'; } else { $pluginlink = $wqurls['wq'] . '/plugins/' . $latestrelease['slug']; echo '
→ ' . esc_html( wqhelper_translate( 'Plugin Home' ) ) . '
'; } } echo '

'; } elseif ( isset( $nextrelease ) && is_array( $nextrelease ) ) { echo '' . esc_html( wqhelper_translate( 'Upcoming Plugin Release' ) ) . '
'; echo '
'; echo '' . esc_attr( wqhelper_translate( 'Next Release Icon' ) ) . '
'; echo '' . esc_html( $nextrelease['title'] ) . ''; echo '
' . esc_html( $nextrelease['description'] ) . '

'; $releasetime = strtotime( $nextrelease['releasedate'] ); echo '
' . esc_html( wqhelper_translate( 'Expected' ) ) . ': ' . esc_html( date( 'jS F Y', $releasetime ) ) . '
'; echo '

'; } // --- feed link styles --- echo ""; // WordQuest Posts Feed // -------------------- $rssurl = $wqurls['wq'] . '/category/guides/feed/'; if ( $wqdebug ) { $feed = ''; delete_transient( 'wordquest_guides_feed' ); } else { $feed = trim( get_transient( 'wordquest_guides_feed' ) ); } // --- fetch posts feed --- if ( !$feed || ( '' == $feed ) ) { $rssfeed = fetch_feed( $rssurl ); $feeditems = 4; $args = array( $rssfeed, $feeditems ); $feed = wqhelper_process_rss_feed( $args ); if ( '' != $feed ) { set_transient( 'wordquest_guides_feed', $feed, ( 24 * 60 * 60 ) ); } } // --- WordQuest Guides ---- echo '
'; echo '
→ ' . esc_html( wqhelper_translate( 'More' ) ) . '...
'; echo '' . esc_html( wqhelper_translate( 'Latest WordQuest Guides' ) ) . '
'; if ( '' != $feed ) { // 1.8.1: use wp_kses_post on feed output echo wp_kses_post( $feed ); } else { echo esc_html( wqhelper_translate( 'Feed Currently Unavailable.' ) ); delete_transient( 'wordquest_guides_feed' ); } echo '
'; // WordQuest Solutions Feed // ------------------------ $rssurl = $wqurls['wq'] . '/quest/feed/'; if ( $wqdebug ) { $feed = ''; delete_transient( 'wordquest_quest_feed' ); } else { $feed = trim( get_transient( 'wordquest_quest_feed' ) ); } // --- fetch solutions feed --- if ( !$feed || ( '' != $feed ) ) { $rssfeed = fetch_feed( $rssurl ); $feeditems = 4; $args = array( $rssfeed, $feeditems ); $feed = wqhelper_process_rss_feed( $args ); if ( '' != $feed ) { set_transient( 'wordquest_quest_feed', $feed, ( 24 * 60 * 60 ) ); } } // --- output solutions feed --- echo '
'; echo '
→ ' . esc_html( wqhelper_translate( 'More' ) ) . '...
'; echo '' . esc_html( wqhelper_translate( 'Latest Solution Quests' ) ) . '
'; if ( '' != $feed ) { // 1.8.1: use wp_kses_post on feed output echo wp_kses_post( $feed ); } else { echo esc_html( wqhelper_translate( 'Feed Currently Unavailable.' ) ); delete_transient( 'wordquest_quest_feed' ); } echo '
'; return; // ----------------------- // Category Feed Selection // ----------------------- // [currently not implented...] /* $pluginsurl = $wqurls['wq'] . '/?get_post_categories=yes'; if ( $wqdebug ) { $categorylist = ''; delete_transient( 'wordquest_feed_cats' ); } else { $categorylist = trim( get_transient( 'wordquest_feed_cats' ) ); } if ( !$categorylist || ( '' == $categorylist ) ) { $args = array( 'timeout' => 10 ); $getcategorylist = wp_remote_get( $pluginsurl, $args ); if ( !is_wp_error( $getcategorylist ) ) { $categorylist = $getcategorylist['body']; if ( $categorylist ) { set_transient( 'wordquest_feed_cats', $categorylist, ( 24 * 60 * 60 ) ); } } } if ( strstr( $categorylist, '::::' ) ) { $categories = explode( '::::', $categorylist ); if ( count( $categories ) > 0 ) { $i = 0; foreach ( $categories as $category ) { $catinfo = explode( '::', $category ); $cats[$i]['name'] = $catinfo[0]; $cats[$i]['slug'] = $catinfo[1]; $cats[$i]['count'] = $catinfo[2]; $i++; } if ( count( $cats ) > 0 ) { echo '
'; echo '' . esc_html( wqhelper_translate( 'Category' ) ) . ':'; echo ''; echo '
'; echo '
'; } } } */ }; } // --------------------------------- // Plugin Review Network Feed Widget // --------------------------------- $funcname = 'wqhelper_pluginreview_feed_widget_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function() { // --- feed link styles --- echo ""; // Latest Plugins Feed // ------------------- global $wqdebug, $wqurls; $rssurl = $wqurls['prn'] . '/feed/'; if ( $wqdebug ) { $feed = ''; delete_transient( 'pluginreview_newest_feed' ); } else { $feed = trim( get_transient( 'pluginreview_newest_feed' ) ); } // --- fetch new plugins feed --- if ( !$feed || ( '' == $feed ) ) { $rssfeed = fetch_feed( $rssurl ); $feeditems = 4; $args = array( $rssfeed, $feeditems ); $feed = wqhelper_process_rss_feed( $args ); if ( '' != $feed ) { set_transient( 'pluginreview_newest_feed', $feed, ( 24 * 60 * 60 ) ); } } echo '
'; echo esc_html( wqhelper_translate( 'NEW' ) ) . ' '; echo esc_html( wqhelper_translate( 'Plugin Directory' ) ) . ' - '; echo esc_html( wqhelper_translate( 'by Category' ) ) . '!

'; echo '
'; // --- ouput latest plugins feed --- echo '
→ ' . esc_html( wqhelper_translate( 'More' ) ) . '...
'; if ( '' != $feed ) { echo '' . esc_html( wqhelper_translate( 'Latest Plugin Releases' ) ) . '
'; // 1.8.1: use wp_kses_post on feed output echo wp_kses_post( $feed ); } else { echo esc_html( wqhelper_translate( 'Feed Currently Unavailable' ) ); delete_transient( 'prn_feed' ); } echo '
'; // Recently Updated Feed // --------------------- $rssurl = $wqurls['prn'] . '/feed/?orderby=modified'; if ( $wqdebug ) { $feed = ''; delete_transient( 'pluginreview_updated_feed' ); } else { $feed = trim( get_transient( 'pluginreview_updated_feed' ) ); } // --- fetch recently updated feed --- if ( !$feed || ( '' == $feed ) ) { $rssfeed = fetch_feed( $rssurl ); $feeditems = 4; $args = array( $rssfeed, $feeditems ); $feed = wqhelper_process_rss_feed( $args ); if ( '' != $feed ) { set_transient( 'pluginreview_updated_feed', $feed, ( 24 * 60 * 60 ) ); } } // --- output recently updated feed --- echo '
'; echo '
→ ' . esc_html( wqhelper_translate( 'More' ) ) . '...
'; if ( '' != $feed ) { echo '' . esc_html( wqhelper_translate( 'Recently Updated Plugins' ) ) . '
'; // 1.8.1: use wp_kses_post on feed output echo wp_kses_post( $feed ); } else { echo esc_html( wqhelper_translate( 'Feed Currently Unavailable' ) ); delete_transient( 'prn_feed' ); } echo '
'; return; // ----------------------- // Category Feed Selection // ----------------------- // [currently not implented...] /* $categoryurl = $wqurls['prn'] . '/?get_review_categories=yes'; // refresh once a day only to limit downloads if ( $wqdebug ) { $categorylist = ''; delete_transient('prn_feed_cats'); } else { $categorylist = trim( get_transient( 'prn_feed_cats' ) ); } if ( !$categorylist || ( '' == $categorylist ) ) { $args = array( 'timeout' => 10 ); $getcategorylist = wp_remote_get( $categoryurl, $args ); if ( !is_wp_error( $getcategorylist ) ) { $categorylist = $getcategorylist['body']; if ( $categorylist ) { set_transient( 'prn_feed_cats', $categorylist, ( 24 * 60 * 60 ) ); } } } if ( strstr( $categorylist, '::::' ) ) { $categories = explode( '::::', $categorylist ); if ( count( $categories) > 0 ) { $i = 0; foreach ( $categories as $category ) { $catinfo = explode( '::', $category); $cats[$i]['name'] = $catinfo[0]; $cats[$i]['slug'] = $catinfo[1]; $cats[$i]['count'] = $catinfo[2]; $i++; } if ( count( $cats ) > 0 ) { echo '
'; echo '' . esc_html( wqhelper_translate( 'Category' ) ) . ':'; echo ''; echo "'; echo '
'; echo '
'; } } } */ }; } // -------------------- // Load a Category Feed // -------------------- $funcname = 'wqhelper_load_feed_category_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function() { global $wqurls; // 1.8.0: remove siteurl usage and validate site key instead // 1.8.1: use sanitize_title on request value // phpcs:ignore WordPress.Security.NonceVerification.Recommended $site = sanitize_title( $_GET['site'] ); if ( !array_key_exists( $site, $wqurls ) ) { return; } $baseurl = $wqurls[$site]; // 1.8.0: use sanitize_title_ on category slug // phpcs:ignore WordPress.Security.NonceVerification.Recommended $catslug = sanitize_title( $_GET['category'] ); $categoryurl = $baseurl . '/category/' . $catslug . '/feed/'; // 1.8.0: set separate URL and use esc_url $moreurl = $baseurl . '/category/' . $catslug . '/'; $morelink = '
→ ' . esc_html( wqhelper_translate( 'More' ) ) . '...
'; // --- fetch the category feed --- $categoryrss = fetch_feed( $categoryurl ); $feeditems = 10; // --- Process the Category Feed --- $args = array( $categoryrss, $feeditems ); $categoryfeed = wqhelper_process_rss_feed( $args ); if ( '' != $categoryfeed ) { $categoryfeed .= $morelink; } // --- send back to parent window --- // 1.8.0: added missing esc_js wrappers on variables echo ""; exit; }; } // ---------------- // Process RSS Feed // ---------------- $funcname = 'wqhelper_process_rss_feed_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function( $args ) { $rss = $args[0]; $feeditems = $args[1]; $processed = ''; if ( is_wp_error( $rss ) ) { return ''; } $maxitems = $rss->get_item_quantity( $feeditems ); $rssitems = $rss->get_items( 0, $maxitems ); if ( 0 == $maxitems ) { $processed = ''; } else { // --- create feed list item display --- $processed = ''; } return $processed; }; } // ----------- // Get Feed Ad // ----------- // 1.8.0: get ad via feed $funcname = 'wqhelper_get_feed_ad_' . $wqhv; if ( !isset( $wqfunctions[$funcname] ) || !is_callable( $wqfunctions[$funcname] ) ) { $wqfunctions[$funcname] = function( $pluginslug ) { global $wqurls; $feedurl = $wqurls['prn'] . '/recommends/?s=1&f=1&c=' . esc_attr( $pluginslug ) . '&t=sidebar'; add_filter( 'wp_feed_cache_transient_lifetime', 'wqhelper_ad_feed_interval' ); $rss = fetch_feed( $feedurl ); remove_filter( 'wp_feed_cache_transient_lifetime', 'wqhelper_ad_feed_interval' ); if ( !$rss || is_wp_error( $rss ) ) { return ''; } $rssitems = $rss->get_items( 0, 1 ); $item = $rssitems[0]; return $item->get_content(); }; } // ---------------------- // Ad Feed Cache Interval // ---------------------- // 1.8.0: added for ad feed interval if ( !function_exists( 'wqhelper_ad_feed_interval' ) ) { function wqhelper_ad_feed_interval( $seconds ) { // --- change feed interval --- return 300; } } // --- manual function list debug point --- // add_action( 'plugins_loaded', function() { // echo ""; // }); // ----------------- // === Changelog === // ----------------- // = 1.8.2 = // - fix to floatbox divs condition when no recommendation // - sanitize HTTP_HOST server global key // = 1.8.1 = // - improved output escaping and sanitization // = 1.8.0 = // - Fix WordPress Coding Standards sniffs // - Change from script ads to feed ads // = 1.7.9 = // - fix to Admin submenu icon styles // = 1.7.8 = // - WordPress Coding Standards redux // - added output escaping sanitization // - fix to sidebar option saving variable // - prefix javascript functions // = 1.7.7 = // - add isset check for plan key for backwards compatibility // = 1.7.6 = // - fix to check if donate link key setting is defined // = 1.7.5 = // - check/fix for Patreon button image URL (cross-versions) // = 1.7.4 = // - simplified PHP 5.3 minimum check // - added Patreon supporter button for WP Medic plugins // - added reminder notice link item icons // - updated Supporter URLs in Usage Reminder Notices // - replaced sidebar footer links for WP Medic plugins // = 1.7.3 = // - only show reminder notice to users with capabilities // = 1.7.2 = // - use superglobal directly in named functions to reduce code // - replaced testimonial link in reminder with share link // - removed testimonial sender box from sidebar // - removed star rating link from sidebar // = 1.7.1 = // - adjust admin menu heading sizes from h3 to h4 // - adjust admin page column max-widths to 300px // = 1.7.0 = // - fix to first plugin install version saving // = 1.6.9 = // - replaced all translation wrappers // - default translation to bioship theme text domain // = 1.6.7 = // - updated wordpress.org review links // - added some missing translation wrappers // = 1.6.6 = // - check wordpress.org only installs/availability // - sanitize posted wqhv version value // - add permission check to debug switch // = 1.6.5 = // - added stickykit to replace float script // - added basic string translation wrappers // - added debug output switch // - split released / upcoming plugin boxes // - fix to latest / next release box // - fix to sidebar options saving call // - fix to admin notice boxer // = 1.6.0 = // - use variable function names // - change function prefix to wqhelper // - text link forms for donations // = 1.5.0 = // - added version checking/loading // - added global admin page // - added admin styles/scripts // - added subscriber levels // - further wordquest conversions // - added freemius submenu styling // - split feed load metaxboxes // - added feed transient storage // - added admin notice boxer // - sidebar options to single array // - AJAXify some helper actions // = 1.4.0 = // - change to wordquest.org // - updated donation amounts // = 1.3.0 = // - added recurring donations // - user email populate bonus form // = 1.2.0 = // - added bonus report form