= 0) { // --------------------------------- // Set this Wordquest Helper version // --------------------------------- // 1.6.0: wqv to wqhv for new variable functions // 1.6.6: move wordquestversion to top for easy changing $wqhv = str_replace('.', '', $wordquestversion); // -------------------- // Set Global Site URLs // -------------------- // 1.6.5: added for clearer/cleaner usage global $wqurls; $wqurls = array( 'wp' => 'https://wordpress.org', 'wq' => 'http://wordquest.org', 'wpm' => 'http://wpmedic.tech', 'prn' => 'http://pluginreview.net', 'bio' => 'http://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 proofing 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 if (!has_action('admin_init', 'wqhelper_admin_loader', 1)) { 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')) { if (isset($_REQUEST['wqdebug']) && ($_REQUEST['wqdebug'] == '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) {echo "";} // --- load callable functions --- // 1.6.0: set the function caller helper global $wqcaller, $wqfunctions; $functionname = 'wqhelper_caller_'; $func = $functionname.$wordquesthelper; // --- set callable functions --- if (is_callable($wqfunctions[$func])) { $wqfunctions[$func]($functionname); // $wqcaller = $wqfunctions[$functionname]; } elseif (function_exists($func)) {call_user_func($func, $functionname);} if ($wqdebug) {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; if (is_callable($wqfunctions[$func])) {return $wqfunctions[$func]($args);} elseif (function_exists($func)) {return call_user_func($func, $args);} }; } }; } // ------------------------------------- // 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 // - wqhelper_sidebar_floatbox // - 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); } } // --- donations box --- 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 // --- 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) { if (!is_admin()) {return;} else {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 --- if (!isset($_POST['wqhv'])) {return;} else {$wqhv = $_POST['wqhv'];} // 1.6.6: added sanitization of version value if (!is_numeric($wqhv) || (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')) {return translate($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() { // --- 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 --- $adminnotices = ''; // $adminnotices = '('.$notices.')'; echo '
'; echo '

'; echo '   '; echo wqhelper_translate('Admin Notices'); echo $adminnotices.'

'; echo '
'; // echo '
'; // echo '

▼ '; // echo wqhelper_translate('Admin Notices'); // echo ' ('.$adminnotices.')

'; // 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') || ( ($pluginslug == 'bioship') && current_user_can('install_themes') ) || ( ($pluginslug != 'bioship') && 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 if ($wqplugin['plan'] == 'premium') {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) { 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; // --- loop reminders --- foreach ($wqreminder as $pluginslug => $reminder) { // --- reminder wrapper --- echo "
"; echo wqhelper_translate("You've been enjoying")." "; echo $wqreminder[$pluginslug]['title']." ".wqhelper_translate("for")." "; echo $wqreminder[$pluginslug]['days']." ".wqhelper_translate("days").". "; echo 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 ""; // --- dismiss notice X link --- $dismisslink = admin_url('admin-ajax.php').'?action=wqhelper_reminder_dismiss&slug='.$pluginslug.'¬ice='.$wqreminder[$pluginslug]['notice']; echo ""; echo "
"; echo "
"; } echo ""; }; } // ----------------------- // AJAX Reminder Dismisser // ----------------------- $funcname = 'wqhelper_reminder_dismiss_'.$wqhv; if (!isset($wqfunctions[$funcname]) || !is_callable($wqfunctions[$funcname])) { $wqfunctions[$funcname] = function() { // --- check conditions --- $pluginslug = $_REQUEST['slug']; $notice = $_REQUEST['notice']; if ( ($notice != '30') && ($notice != '90') && ($notice != '365') ) {return;} // --- check capabilities --- $dismiss = false; if ( current_user_can('manage_options') || ( ($pluginslug == 'bioship') && current_user_can('install_themes') ) || ( ($pluginslug != 'bioship') && 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']) && ($sidebaroptions[$notice.'days'] == 'dismissed')) { $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'); if ($wqdebug) {$plugininfo = '';} // clear transient for debugging // --- 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) {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 echo wqhelper_sidebar_stickykitscript(); 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 '

'.wqhelper_translate('Join').'

/

'.wqhelper_translate('Login').'

'.wqhelper_translate('Solutions').'

'.wqhelper_translate('Contribute').'

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

Source Info

'; echo "
"; echo ""; echo ""; echo ""; echo "
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 $wordpressorgonly; $wordpressorgonly = true; foreach ($wordquestplugins as $pluginslug => $plugin) { // if this is false, it was from wordquest not wordpress if (!$plugin['wporg']) {$wordpressorgonly = 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; foreach ($wordquestplugins as $pluginslug => $values) {$pluginslugs[$i] = $pluginslug; $i++;} // if ($wqdebug) {echo "";} // --- Get All Installed Plugins Info --- $i = 0; $installedplugins = get_plugins(); 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']) && ($plugin['latestrelease'] == 'yes')) { $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']) && ($plugin['nextrelease'] == 'yes')) { $wqplugins[$pluginslug]['nextrelease'] = 'yes'; $nextrelease = $wqplugins[$pluginslug]; $nextrelease['slug'] = $pluginslug; } } } } // if ($wqdebug) {echo "";} if ($wqdebug) {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 = array(); $inactiveplugins = 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)) { $inactiveplugins[$j] = $pluginslug; $j++; $inactiveversions[$pluginslug] = $values['Version']; } $i++; } } // if ($wqdebug) {echo "";} // if ($wqdebug) {echo "";} // --- check if BioShip Theme installed --- $themes = wp_get_themes(); $bioshipinstalled = false; foreach ($themes as $theme) {if ($theme->stylesheet == 'bioship') {$bioshipinstalled = true;} } // --- open plugin column --- echo '
'; // Active Plugin Panel // ------------------- $boxid = 'wordquestactive'; $boxtitle = wqhelper_translate('Active WordQuest Plugins'); echo '
'; echo '

'.$boxtitle.'

'; echo '
'; foreach ($wordquestplugins as $pluginslug => $plugin) { if ($pluginslug != 'bioship') { // filter out theme here // --- 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 ""; echo ""; // --- update / settings options --- echo ""; // --- do selected action button --- echo ""; } } echo '
"; echo $plugin['title']."".$plugin['version'].""; echo "
'; // Inactive Plugin Panel // --------------------- if (count($inactiveplugins) > 0) { $boxid = 'wordquestinactive'; $boxtitle = wqhelper_translate('Inactive WordQuest Plugins'); echo '
'; echo '

'.$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]; $updatelink = wp_nonce_url($updatelink, 'upgrade-plugin_'.$pluginfiles[$inactiveplugins]); echo ""; } // --- linked title and version --- echo ""; echo ""; // --- select plugin action --- echo ""; // --- plugin action button --- echo ""; echo ""; } echo '
"; echo $wqplugins[$inactiveplugin]['title']."".$inactiveversions[$inactiveplugin].""; echo "
'; } $releasedplugins = $unreleasedplugins = array(); if ( count($wqplugins) > count($wordquestplugins) ) { foreach ($wqplugins as $pluginslug => $wqplugin) { if (!in_array($pluginslug, $installedslugs) && !in_array($pluginslug, $inactiveplugins)) { if ($wqplugin['releasestatus'] == 'Released') {$releasedplugins[$pluginslug] = $wqplugin;} else { $releasetime = strtotime($wqplugin['releasedate']); $wqplugin['slug'] = $pluginslug; $unreleasedplugins[$releasetime] = $wqplugin; } } } } // Available Plugin Panel // ---------------------- if (count($releasedplugins) > 0) { if ($wqdebug) {echo "";} $boxid = 'wordquestavailable'; $boxtitle = wqhelper_translate('Available WordQuest Plugins'); echo '
'; echo '

'.$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 ($wordpressorgonly && $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 (!$wordpressorgonly && 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 $wqplugin['title']."".$wqplugin['version'].""; echo "
"; } // Upcoming Plugin Panel // --------------------- if (count($unreleasedplugins) > 0) { ksort($unreleasedplugins); if ($wqdebug) {echo "";} $boxid = 'wordquestupcoming'; $boxtitle = wqhelper_translate('Upcoming WordQuest Plugins'); echo '
'; echo '

'.$boxtitle.'

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

'.$boxtitle.'

'; echo '
'; if ($bioshipinstalled) { // --- check if BioShip Theme is active --- $theme = wp_get_theme(); if ($theme->stylesheet == 'bioship') { echo wqhelper_translate('Sweet! You are using').' '; echo wqhelper_translate('BioShip Theme Framework').'.
'; echo 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 ''.wqhelper_translate('Theme Options').''; } elseif (is_child_theme() && ($theme->template == 'bioship')) { echo wqhelper_translate('Groovy. You are using').' '; echo wqhelper_translate('BioShip Framework').'!
'; echo wqhelper_translate('Your Child Theme is').' '.$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 ''.wqhelper_translate('Theme Options').''; } else { echo wqhelper_translate('Looks like you have BioShip installed!').'
'; echo '...'.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 ''.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 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 wqhelper_translate('or').', '; echo 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='.urlencode('theme-test-drive/themedrive.php'); $activatelink = wp_nonce_url($activatelink,'activate-plugin_theme-test-drive/themedrive.php'); echo wqhelper_translate('or').', '; echo wqhelper_translate('activate Theme Test Drive plugin').'
'; echo 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 wqhelper_translate('or').', '; echo wqhelper_translate('install Theme Test Drive plugin').'
'; echo wqhelper_translate('to test BioShip without affecting your current site.'); } echo "
"; } } else { echo wqhelper_translate('Also from').' WordQuest Alliance, '.wqhelper_translate('check out the').'
'; echo "BioShip Theme Framework
"; echo wqhelper_translate('A highly flexible and responsive starter theme').'
'.wqhelper_translate('for users, designers and developers.'); } if ( ($theme->template == 'bioship') || ($theme->stylesheet == 'bioship') ) { // 1.7.3: addded missing function prefix if (function_exists('bioship_admin_theme_updates_available')) { $themeupdates = bioship_admin_theme_updates_available(); if ($themeupdates != '') { echo '
'.$themeupdates.'

'; } } // TODO: future link for rating BioShip on wordpress.org theme repository ? // $ratelink = 'https://wordpress.org/support/theme/bioship/reviews/#new-post'; // echo '
'.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) { // --- 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 ($latestrelease['installed'] == 'no') { $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 '

'.$boxtitle.'

'; echo '
'; echo "
"; echo "

"; echo "".$release['title']."
".$release['description']."

"; if (isset($release['package']) && is_array($release['package'])) { // 1.6.6: check for wordpress.org only installs global $wordpressorgonly; $installlink = false; if ($wordpressorgonly && $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 "
".wqhelper_translate('Install Now')."
"; } else { $pluginlink = $wqurls['wq'].'/plugins/'.$release['slug']; echo "
→ ".wqhelper_translate('Plugin Home')."
"; } } else {echo "
".wqhelper_translate('Expected').": ".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 '

'.$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 '

'.$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 --- 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( 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( wqhelper_translate('Error: No Plugin specified.') );} $pluginslug = $_REQUEST['plugin']; // 1.5.9: sanitize plugin slug $pluginslug = sanitize_title($pluginslug); if ($pluginslug == '') {wp_dir( 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 ($response['response']['code'] == '404') { // --- on failure try to get package info from stored transient data --- $plugininfo = get_transient('wordquest_plugin_info'); if (is_array($pluginfo)) { foreach ($plugininfo as $plugin) { if ($plugin['slug'] == $pluginslug) {$pluginpackage = $plugin['package'];} } } } else {$pluginpackage = json_decode($response['body'], true);} } if (!isset($pluginpackage)) { if (is_ssl()) {$tryagainurl = 'https://';} else {$tryagainurl = 'http://';} $tryagainurl .= $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']; $message = wqhelper_translate('Failed to retrieve download package information.'); $message .= ' '.wqhelper_translate('Click here to try again.').''; wp_die($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'; $args = compact('type', 'title', 'nonce', 'url'); // --- custom Plugin_Upgrader (via /wp-admin/upgrade.php) --- $title = wqhelper_translage('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) {echo "";} if (count($args) == 7) { // --- the old way, sending all args individually --- $prefix = $args[0]; $pluginslug = $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']; $freepremium = $wordquestplugins[$slug]['plan']; $wporg = $wordquestplugins[$slug]['wporg']; if (isset($wordquestplugins[$slug]['wporgslug'])) { $wporgslug = $wordquestplugins[$slug]['wporgslug']; } else {$wporgslug = '';} if ($wqdebug) {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 == '') || !is_array($sidebaroptions) ) { $sidebaroptions['installdate'] = date('Y-m-d'); $sidebaroptions['adsboxoff'] = get_option($prefix.'_ads_box_off'); $sidebaroptions['donationboxoff'] = get_option($prefix.'_donation_box_off'); $sidebaroptions['reportboxoff'] = get_option($prefix.'_report_box_off'); delete_option($prefix.'_ads_box_off'); delete_option($prefix.'_donation_box_off'); delete_option($prefix.'_report_box_off'); add_option($prefix.'_sidebar_options', $sidebaroptions); } // 1.6.9: fix to possible undefined keys if (!isset($sidebaroptions['installdate'])) {$sidebaroptions['installdate'] = date('Y-m-d');} if (!isset($sidebaroptions['adsboxoff'])) {$sidebaroptions['adsboxoff'] = '';} if (!isset($sidebaroptions['donationboxoff'])) {$sidebaroptions['donationboxoff'] = '';} if (!isset($sidebaroptions['reportboxoff'])) {$sidebaroptions['reportboxoff'] = '';} // --- sidebar scripts --- 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 ($savebutton != 'replace') { echo '
'; echo '

'.wqhelper_translate('Update Settings').'

'; if ($savebutton == 'yes') { $buttonoutput = ""; $buttonoutput .= ""; $buttonoutput .= ""; $buttonoutput .= ""; $buttonoutput .= ""; $buttonoutput .= "
"; $buttonoutput = apply_filters('wordquest_sidebar_save_button', $buttonoutput); echo $buttonoutput; } elseif ($savebutton == 'no') {echo "";} else {echo "";} // --- sidebar settings box --- echo "
"; echo '
'; } // Donation Box // ------------ // for Free Version? Or Upgrade Link? $args = array($prefix, $pluginslug); if ($sidebaroptions['donationboxoff'] == 'checked') {$hide = " style='display:none;'>";} else {echo $hide = '';} echo ''; // Bonus Subscription Form // ----------------------- // 1.7.2: allow for bonus offer box override $funcname = $prefix.'_sidebar_bonus_offer'; if (function_exists($funcname)) {call_user_func($funcname);} else { // --- populated form for current user --- global $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;} // --- set report image URL --- if ($pluginslug == 'bioship') {$reportimage = get_template_directory_uri()."/images/rv-report.jpg";} else {$reportimage = plugins_url('images/rv-report.jpg', __FILE__);} echo ''; } // PluginReview.Net Plugin Recommendations // --------------------------------------- if ($sidebaroptions['adsboxoff'] != 'checked') { // 1.7.2: allow for recommendation box override $funcname = $prefix.'_sidebar_plugin_recommendation'; if (function_exists($funcname)) {call_user_func($funcname);} else { echo '
'; echo '
'; echo '

'.wqhelper_translate('Recommended').'

'; echo ""; echo '
'; } } // Call Plugin Footer Function // --------------------------- $funcname = $prefix.'_sidebar_plugin_footer'; if (function_exists($funcname)) {call_user_func($funcname);} else { // Default Sidebar Plugin Footer // ----------------------------- // --- set values for theme or plugin --- if ($pluginslug == 'bioship') { $iconurl = get_template_directory_uri().'/images/wordquest.png'; $pluginurl = $wqurls['bio']; $pluginfootertitle = wqhelper_translate('Theme Info'); } else { $iconurl = plugins_url("images/wordquest.png", __FILE__); $pluginurl = $wqurls['wq']."/plugins/".$pluginslug."/"; $pluginfootertitle = wqhelper_translate('Plugin Info'); } echo '

'.$pluginfootertitle.'

'; echo "
"; echo ""; echo ""; echo ""; echo "
".$plugintitle." v".$pluginversion."
"; echo "by WordQuest Alliance
"; echo "→ ".wqhelper_translate('More Cool Plugins')."
"; echo "→ ".wqhelper_translate('Plugin Directory')."
"; echo '
'; } // --- close sidebar float div --- 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]; // --- maybe call special top --- if (function_exists($prefix.'_donations_special_top')) { $funcname = $prefix.'_donations_special_top'; call_user_func($funcname); } // --- make display name from the plugin slug --- if (strstr($pluginslug, '-')) { $parts = explode('-', $pluginslug); $i = 0; foreach ($parts as $part) { if ($part == 'wp') {$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 " ".wqhelper_translate('Supporter')." "; echo ""; echo " ".wqhelper_translate('One Time').""; echo "
"; // --- set weekly amount options --- // 1.5.0: added weekly amounts echo '
'; // --- set monthly amount options --- // 1.5.0: added monthly amounts echo '
'; // note: eStore recurring subscription form // $wqurls['wq'].'/?wp_eStore_subscribe=LEVEL&c_input='.$pluginslug; // --- set donate image URL --- if ($pluginslug == 'bioship') {$donateimage = get_template_directory_uri()."/images/pp-donate.jpg";} else {$donateimage = plugins_url("/images/pp-donate.jpg", __FILE__);} // --- recurring donation form --- echo '
'; /// --- one time donation form --- // $wqurls['wq'].'/?wp_eStore_donation=23&var1_price=AMOUNT&c_input='.$pluginslug; echo '
'; // --- call donations special bottom --- if (function_exists($prefix.'_donations_special_bottom')) { $funcname = $prefix.'_donations_special_bottom'; call_user_func($funcname); } }; } // --------------- // 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 "
".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() { $pre = $_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['donationboxoff'] = $sidebaroptions['reportboxoff'] = ''; if (isset($_POST[$prefix.'_ads_box_off']) && ($_POST[$prefix.'_ads_box_off'] == 'checked')) {$sidebaroptions['adsboxoff'] = 'checked';} if (isset($_POST[$prefix.'_donation_box_off']) && ($_POST[$prefix.'_donation_box_off'] == 'checked')) {$sidebaroptions['donationboxoff'] = 'checked';} if (isset($_POST[$prefix.'_report_box_off']) && ($_POST[$prefix.'_report_box_off'] == 'checked')) {$sidebaroptions['reportboxoff'] = 'checked';} update_option($prefix.'_sidebar_options', $sidebaroptions); // print_r($sidebaroptions); // debug point // --- javascript response callbacks --- echo ""; // --- maybe call Special Update Options --- $funcname = $prefix.'_update_sidebar_options_special'; if (function_exists($funcname)) {call_user_func($funcname);} } exit; }; } // --------------------- // Sticky Kit Javascript // --------------------- $funcname = 'wqhelper_sidebar_stickykitscript_'.$wqhv; if (!isset($wqfunctions[$funcname]) || !is_callable($wqfunctions[$funcname])) { $wqfunctions[$funcname] = function() { return ''; }; } // ' // --------------------- // Float Menu Javascript // --------------------- $funcname = 'wqhelper_sidebar_floatmenuscript_'.$wqhv; if (!isset($wqfunctions[$funcname]) || !is_callable($wqfunctions[$funcname])) { $wqfunctions[$funcname] = function() { return " "; }; } // ----------------------------- // === Dashboard Feed Widget === // ----------------------------- // ----------------------------- // Add the Dashboard Feed Widget // ----------------------------- $requesturi = $_SERVER['REQUEST_URI']; if ( (preg_match('|index.php|i', $requesturi)) || (substr($requesturi, -(strlen('/wp-admin/'))) == '/wp-admin/') || (substr($requesturi, -(strlen('/wp-admin/network'))) == '/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 ($name == 'wordquest') {$wordquestloaded = true;} if ($name == 'pluginreview') {$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() { 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']) && ($plugin['latestrelease'] == 'yes')) || (isset($plugin['nextrelease']) && ($plugin['nextrelease'] == 'yes')) ) { $plugininfo = $plugin; $plugins = get_plugins(); $plugininfo['installed'] = 'no'; foreach ($plugins as $pluginfile => $values) { if ($plugininfo['slug'] == sanitize_title($values['Name'])) {$plugininfo['installed'] = 'yes';} } } if (isset($plugin['latestrelease']) && ($plugin['latestrelease'] == 'yes')) {$latestrelease = $plugininfo;} if (isset($plugin['nextrelease']) && ($plugin['nextrelease'] == 'yes')) {$nextrelease = $plugininfo;} } } } } // echo ""; // echo ""; // maybe Display Latest Release Info // --------------------------------- if (isset($_REQUEST['page']) && ($_REQUEST['page'] == 'wordquest')) { // --- do not duplicate here as already output for wordquest page --- } elseif (isset($latestrelease) && is_array($latestrelease) && ($latestrelease['installed'] == 'no')) { echo "".wqhelper_translate('Latest Plugin Release')."
"; echo ""; echo "

"; echo "".$latestrelease['title']."
".$latestrelease['description']."

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

"; } elseif (isset($nextrelease) && is_array($nextrelease)) { echo "".wqhelper_translate('Upcoming Plugin Release')."
"; echo ""; echo "

"; echo "".$nextrelease['title']."
".$nextrelease['description']."

"; $releasetime = strtotime($nextrelease['releasedate']); echo "
".wqhelper_translate('Expected').": ".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 "
".wqhelper_translate('More')."...
"; echo "".wqhelper_translate('Latest WordQuest Guides')."
"; if ($feed != '') {echo $feed;} else {echo 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 "
".wqhelper_translate('More')."...
"; echo "".wqhelper_translate('Latest Solution Quests').""; if ($feed != '') {echo $feed;} else {echo wqhelper_translate('Feed Currently Unavailable.'); delete_transient('wordquest_quest_feed');} echo "
"; return; // -------------------------- // currently not implented... // Category Feed Selection // ----------------------- $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 ""; echo "
".wqhelper_translate('Category').":
"; 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 wqhelper_translate('NEW', 'bioship').' '.wqhelper_translate('Plugin Directory')." - ".wqhelper_translate('by Category')."!

"; echo "
"; // --- ouput latest plugins feed --- echo "
".wqhelper_translate('More')."...
"; if ($feed != '') {echo "".wqhelper_translate('Latest Plugin Releases')."
".$feed;} else {echo 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 "
".wqhelper_translate('More')."...
"; if ($feed != '') {echo "".wqhelper_translate('Recently Updated Plugins')."
".$feed;} else {echo wqhelper_translate('Feed Currently Unavailable'); delete_transient('prn_feed');} echo "
"; return; // -------------------------- // currently not implented... // Category Feed Selection // ----------------------- $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 ""; echo "
".wqhelper_translate('Category').":
"; echo "
"; } } } }; } // -------------------- // Load a Category Feed // -------------------- $funcname = 'wqhelper_load_feed_category_'.$wqhv; if (!isset($wqfunctions[$funcname]) || !is_callable($wqfunctions[$funcname])) { $wqfunctions[$funcname] = function() { $namespace = $_GET['namespace']; $baseurl = $_GET['siteurl']; $catslug = $_GET['category']; $categoryurl = $baseurl."/category/".$catslug."/feed/"; $morelink = "
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 --- 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 ($maxitems == 0) {$processed = '';} else { // --- create feed list item display --- $processed = ""; } return $processed; }; } // CLOSE VERSION COMPARE WRAPPER FOR PHP 5.3 REQUIRED // -------------------------------------------------- } // --- manual function debug point --- // print_r($wqfunctions); // ------------------------ // === Helper Changelog === // ------------------------ // = 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