'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 '
';
// --- 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 '';
}
}
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 '
';
// Inactive Plugin Panel
// ---------------------
if ( count( $inactiveplugins ) > 0 ) {
$boxid = 'wordquestinactive';
$boxtitle = wqhelper_translate( 'Inactive WordQuest Plugins' );
echo '
';
echo '
';
echo '' . esc_html( $boxtitle ) . ' ';
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 '
';
}
// 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 esc_html( $wqplugin['title'] ) . ' ';
echo ' ';
echo '';
echo esc_html( wqhelper_translate( 'Expected' ) ) . ': ' . esc_html( date( 'jS F Y', $releasetime ) );
echo ' ';
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 ' ';
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 '';
echo ' ';
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 '
';
}
echo '>';
// 1.7.2: remove testimonial box from sidebar
// wqhelper_sidebar_testimonial_box( $args );
echo '
';
}
// Bonus Report Subscription Form
// ------------------------------
// 1.7.2: allow for bonus offer box override
if ( in_array( 'report', $boxes ) ) {
echo '
';
}
echo '>';
$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 ( 'bioship' == $pluginslug ) {
$reportimage = get_template_directory_uri() . '/images/rv-report.jpg';
} else {
$reportimage = plugins_url( 'images/rv-report.jpg', __FILE__ );
}
echo '
';
echo '
' . esc_html( wqhelper_translate( 'Bonus Offer' ) ) . ' ';
echo '
';
}
echo '
';
}
// PluginReview.Net Plugin Recommendations
// ---------------------------------------
if ( in_array( 'recommend', $boxes ) ) {
echo '
';
// 1.7.2: allow for recommendation box override
$funcname = $prefix . '_sidebar_plugin_recommendation';
if ( function_exists( $funcname ) ) {
call_user_func( $funcname );
} else {
// 1.8.0: check for contents before box output
$feedad = wqhelper_get_feed_ad( $pluginslug );
if ( $feedad ) {
echo '
';
echo '
' . esc_html( wqhelper_translate( 'Recommended' ) ) . ' ';
echo '
';
if ( 'checked' != $sidebaroptions['adsboxoff'] ) {
// 1.8.0: replaced script with RSS feed ad
// echo '';
// 1.8.1: use wp_kses_post on feed ad
echo wp_kses_post( $feedad );
}
// 1.8.2: fix to move close divs back inside condition
echo '
';
}
}
echo '
';
}
// Call Plugin Footer Function
// ---------------------------
$funcname = $prefix . '_sidebar_plugin_footer';
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 ' ';
// --- set weekly amount options ---
// 1.5.0: added weekly amounts
echo '';
echo ' ';
echo '';
echo '';
echo '' . esc_html( wqhelper_translate( 'Copper' ) ) . ': $1 ';
echo '' . esc_html( wqhelper_translate( 'Bronze' ) ) . ': $2 ';
echo '' . esc_html( wqhelper_translate( 'Silver' ) ) . ': $4 ';
echo '' . esc_html( wqhelper_translate( 'Gold' ) ) . ': $5 ';
echo '' . esc_html( wqhelper_translate( 'Platinum' ) ) . ': $7.50 ';
echo '' . esc_html( wqhelper_translate( 'Titanium' ) ) . ': $10 ';
echo '' . esc_html( wqhelper_translate( 'Star Ruby' ) ) . ': $12.50 ';
echo '' . esc_html( wqhelper_translate( 'Star Topaz' ) ) . ': $15 ';
echo '' . esc_html( wqhelper_translate( 'Star Emerald' ) ) . ': $17.50 ';
echo '' . esc_html( wqhelper_translate( 'Star Sapphire' ) ) . ': $20 ';
echo '' . esc_html( wqhelper_translate( 'Star Diamond' ) ) . ': $25 ';
echo '
';
// --- set monthly amount options ---
// 1.5.0: added monthly amounts
echo '';
echo ' ';
echo '';
echo '';
echo '' . esc_html( wqhelper_translate( 'Copper' ) ) . ': $5 ';
echo '' . esc_html( wqhelper_translate( 'Bronze' ) ) . ': $10 ';
echo '' . esc_html( wqhelper_translate( 'Silver' ) ) . ': $15 ';
echo '' . esc_html( wqhelper_translate( 'Gold' ) ) . ': $20 ';
echo '' . esc_html( wqhelper_translate( 'Platinum' ) ) . ': $30 ';
echo '' . esc_html( wqhelper_translate( 'Titanium' ) ) . ': $40 ';
echo '' . esc_html( wqhelper_translate( 'Star Ruby' ) ) . ': $50 ';
echo '' . esc_html( wqhelper_translate( 'Star Topaz' ) ) . ': $60 ';
echo '' . esc_html( wqhelper_translate( 'Star Emerald' ) ) . ': $70 ';
echo '' . esc_html( wqhelper_translate( 'Star Sapphire' ) ) . ': $80 ';
echo '' . esc_html( wqhelper_translate( 'Star Diamond' ) ) . ': $100 ';
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 '