function spa_themes_list_form() { global $spPaths; # get current theme $curTheme = sp_get_option('sp_current_theme'); # get themes $themes = sp_get_themes_list_data(); # get update version info $xml = sp_load_version_xml(); spa_paint_options_init(); spa_paint_open_tab(spa_text('Available Themes') . '- ' . spa_text('Select Simple:Press Theme'), true); spa_paint_open_panel(); spa_paint_spacer(); echo '<div class="sfoptionerror">'; echo spa_text('Themes Folder') . ': <b>' . realpath(SF_STORE_DIR . '/' . $spPaths['themes']) . '</b>'; echo '</div>'; spa_paint_open_fieldset(spa_text('Theme Management'), true, 'themes'); ?> <h3><?php echo spa_text('Current Theme'); ?> </h3> <div class="theme-browser rendered"> <div class="spThemeContainer"> <div id="current-theme" class="spTheme"> <?php if (file_exists(SPTHEMEBASEDIR . $curTheme['theme'] . '/styles/' . $curTheme['style'])) { ?> <h3 class="theme-name"><?php echo $themes[$curTheme['theme']]['Name']; ?> </h3> <img src="<?php echo SPTHEMEBASEURL . $curTheme['theme'] . '/' . $themes[$curTheme['theme']]['Screenshot']; ?> " alt="" /> <h4> <?php echo $themes[$curTheme['theme']]['Name'] . ' ' . $themes[$curTheme['theme']]['Version'] . ' ' . spa_text('by') . ' <a href="' . $themes[$curTheme['theme']]['AuthorURI'] . '" title="' . spa_text('Visit author homepage') . '">' . $themes[$curTheme['theme']]['Author'] . '</a>'; ?> </h4> <?php if (!empty($curTheme['parent'])) { if (file_exists(SPTHEMEBASEDIR . $curTheme['parent'])) { echo '<p class="theme-parent">'; echo spa_text('This theme is a child theme of ') . '<b>' . $curTheme['parent'] . '</b>'; echo '</p>'; } else { echo '<p class="theme-parent">'; echo '<b>' . spa_text('The specified parent theme') . " '" . $curTheme['parent'] . "' " . spa_text('does not exist') . '</b> '; echo '</p>'; } } ?> <p class="description" style="padding: 0;"> <?php echo $themes[$curTheme['theme']]['Description']; ?> </p> <?php $overlays = sp_get_overlays(SPTHEMEBASEDIR . $curTheme['theme'] . '/styles/overlays'); # pull in parent overlays if child theme if (!empty($curTheme['parent'])) { $parent_overlays = sp_get_overlays(SPTHEMEBASEDIR . $curTheme['parent'] . '/styles/overlays'); $overlays = array_merge($overlays, $parent_overlays); $overlays = array_unique($overlays); } if (!empty($overlays)) { ?> <script type="text/javascript"> jQuery(document).ready(function() { spjAjaxForm('sftheme-<?php echo esc_js($curTheme['theme']); ?> ', 'sfreloadtlist'); }); </script> <br /> <?php $ahahURL = SFHOMEURL . 'index.php?sp_ahah=themes-loader&sfnonce=' . wp_create_nonce('forum-ahah') . '&saveform=theme'; echo '<form action="' . $ahahURL . '" method="post" id="sftheme-' . esc_attr($curTheme['theme']) . '" name="sftheme-' . esc_attr($curTheme['theme']) . '">'; echo sp_create_nonce('forum-adminform_themes'); echo '<input type="hidden" name="theme" value="' . esc_attr($curTheme['theme']) . '" />'; echo '<input type="hidden" name="style" value="' . esc_attr($themes[$curTheme['theme']]['Stylesheet']) . '" />'; echo '<input type="hidden" name="parent" value="' . esc_attr($curTheme['parent']) . '" />'; echo '<input type="hidden" name="default-color" value="' . esc_attr($overlays[0]) . '" />'; echo spa_text('Select Overlay') . ': '; echo '<select name="color-' . esc_attr($curTheme['theme']) . '">'; foreach ($overlays as $overlay) { $overlay = trim($overlay); $selected = $curTheme['color'] == $overlay ? ' selected="selected" ' : ''; echo '<option' . $selected . ' value="' . esc_attr($overlay) . '">' . esc_html($overlay) . '</option>'; } echo '</select> '; echo ' <input type="submit" class="button-secondary action" id="update" name="update" value="' . spa_text('Update Overlay') . '" />'; echo '</form>'; } # any upgrade for this theme? in multisite only main site can update if (is_main_site() && $xml) { foreach ($xml->themes->theme as $latest) { if ($themes[$curTheme['theme']]['Name'] == $latest->name) { if (version_compare($latest->version, $themes[$curTheme['theme']]['Version'], '>') == 1) { echo '<br />'; echo '<p style="padding: 0;">'; echo '<strong>' . spa_text('There is an update for the') . ' ' . $themes[$curTheme['theme']]['Name'] . ' ' . spa_text('theme') . '.</strong> '; echo spa_text('Version') . ' ' . $latest->version . ' ' . spa_text('is available') . '. '; echo spa_text('For details and to download please visit') . ' ' . SFPLUGHOME . ' ' . spa_text('or') . ' ' . spa_text('go to the') . ' '; echo '<a href="' . self_admin_url('update-core.php') . '" title="" target="_parent">' . spa_text('WordPress updates page') . '</a>'; echo '</p>'; } break; } } } } else { echo '<h4>' . spa_text('The current theme stylesheet') . ':<br /><br />' . SPTHEMEBASEDIR . $curTheme['theme'] . '/styles/' . $curTheme['style'] . '<br /><br />' . spa_text('cannot be found. Please correct or select a new theme for proper operation.') . '</h4>'; } ?> </div></div></div> <br class="clear" /> <h3><?php echo spa_text('Available Themes'); ?> </h3> <?php $numThemes = count($themes); if ($numThemes > 1) { ?> <div class="theme-browser rendered"> <div class="spThemeContainer"> <?php foreach ((array) $themes as $theme_file => $theme_data) { # skip cur theme if ($theme_file == $curTheme['theme']) { continue; } $theme_desc = $theme_data['Description']; $theme_name = $theme_data['Name']; $theme_version = $theme_data['Version']; $theme_author = $theme_data['Author']; $theme_uri = $theme_data['AuthorURI']; $theme_style = $theme_data['Stylesheet']; $theme_image = SPTHEMEBASEURL . $theme_file . '/' . $theme_data['Screenshot']; $theme_overlays = sp_get_overlays(SPTHEMEBASEDIR . $theme_file . '/styles/overlays'); # pull in parent overlays if child theme if (!empty($theme_data['Parent'])) { $parent_overlays = sp_get_overlays(SPTHEMEBASEDIR . $theme_data['Parent'] . '/styles/overlays'); $theme_overlays = array_merge($theme_overlays, $parent_overlays); } ?> <div class="spTheme"> <h3 class="theme-name"><?php echo $theme_name; ?> </h3> <img alt="" src="<?php echo $theme_image; ?> " /> <h4> <?php echo $theme_name . ' ' . $theme_version . ' ' . spa_text('by') . ' <a href="' . $theme_uri . '" title="' . spa_text('Visit author homepage') . '">' . $theme_author . '</a>'; ?> </h4> <?php if (!empty($theme_data['Parent'])) { if (file_exists(SPTHEMEBASEDIR . $theme_data['Parent'])) { echo '<p class="theme-parent">'; echo spa_text('This theme is a child theme of ') . '<b>' . $theme_data['Parent'] . '</b>'; echo '</p>'; } else { echo '<p class="theme-parent">'; echo '<b>' . spa_text('The specified parent theme') . " '" . $theme_data['Parent'] . "' " . spa_text('does not exist') . '</b> '; echo '</p>'; } } ?> <p class="description" style="padding: 0;"> <?php echo $theme_desc; ?> </p> <br /> <div class="action-links"> <script type="text/javascript"> jQuery(document).ready(function() { spjAjaxForm('sftheme-<?php echo esc_js($theme_file); ?> ', 'sfreloadtlist'); }); </script> <?php $ahahURL = SFHOMEURL . 'index.php?sp_ahah=themes-loader&sfnonce=' . wp_create_nonce('forum-ahah') . '&saveform=theme'; ?> <?php $msg = esc_js(spa_text('Are you sure you want to delete this Simple Press theme?')); ?> <form action="<?php echo $ahahURL; ?> " method="post" id="sftheme-<?php echo esc_attr($theme_file); ?> " name="sftheme-<?php echo esc_attr($theme_file); ?> " > <?php echo sp_create_nonce('forum-adminform_themes'); ?> <input type="hidden" name="theme" value="<?php echo esc_attr($theme_file); ?> " /> <input type="hidden" name="style" value="<?php echo esc_attr($theme_style); ?> " /> <input type="hidden" name="parent" value="<?php echo esc_attr($theme_data['Parent']); ?> " /> <?php $defOverlay = !empty($theme_overlays) ? esc_attr($theme_overlays[0]) : 0; echo "<input type='hidden' name='default-color' value='{$defOverlay}' />"; if ($theme_overlays) { echo spa_text('Select Overlay') . ': '; echo ' <select name="color-' . esc_attr($theme_file) . '" style="margin-bottom:5px;">'; foreach ($theme_overlays as $theme_overlay) { $theme_overlay = trim($theme_overlay); $selected = $theme_overlays[0] == $theme_overlay ? ' selected="selected" ' : ''; echo '<option' . $selected . ' value="' . esc_attr($theme_overlay) . '">' . esc_html($theme_overlay) . '</option>'; } echo '</select> '; echo '<div class="clearboth"></div>'; } ?> <input type="submit" class="button-secondary action" id="activate-<?php echo esc_attr($theme_file); ?> " name="activate" value="<?php echo spa_etext('Activate Theme'); ?> " /> <?php if (!is_multisite() || is_super_admin()) { ?> <input type="submit" class="button-secondary action" id="delete-<?php echo esc_attr($theme_file); ?> " name="delete" value="<?php echo spa_etext('Delete Theme'); ?> " onclick="javascript: if (confirm('<?php echo $msg; ?> ')) {return true;} else {return false;}" /><?php } ?> </form> </div> <?php # any upgrade for this theme? if ($xml) { foreach ($xml->themes->theme as $latest) { if ($theme_data['Name'] == $latest->name) { if (version_compare($latest->version, $theme_data['Version'], '>') == 1) { echo '<br />'; echo '<div class="plugin-update-tr"><div class="update-message" style="background-color:#fcf3ef;margin-left:10px;">'; echo '<strong>' . spa_text('There is an update for the') . ' ' . $theme_data['Name'] . ' ' . spa_text('theme') . '.</strong> '; echo spa_text('Version') . ' ' . $latest->version . ' ' . spa_text('is available') . '. '; echo spa_text('For details and to download please visit') . ' ' . SFPLUGHOME . ' ' . spa_text('or') . ' ' . spa_text('go to the') . ' '; echo '<a href="' . self_admin_url('update-core.php') . '" title="" target="_parent">' . spa_text('WordPress updates page') . '</a>'; echo '</div></div>'; } break; } } } echo '</div>'; } echo "</div>"; echo '</div>'; } else { echo spa_text('No other available themes found'); } do_action('sph_themes_list_panel'); spa_paint_close_fieldset(); spa_paint_close_panel(); spa_paint_close_container(); spa_paint_close_tab(); }
function sp_check_for_updates() { $xml = sp_load_version_xml(); if ($xml) { $installed_version = sp_get_option('sfversion'); $installed_build = sp_get_option('sfbuild'); if (empty($installed_build)) { return; } if ($xml->core->build > $installed_build) { $up = get_site_transient('update_plugins'); $data = new stdClass(); $data->slug = 'simple-press'; $data->new_version = (string) $xml->core->version . ' Build ' . (string) $xml->core->build; $data->new_build = (string) $xml->core->build; $data->upgrade_notice = (string) $xml->core->message; $data->url = 'http://simple-press.com'; $data->package = (string) $xml->core->archive; $up->response['simple-press/sp-control.php'] = $data; set_site_transient('update_plugins', $up); } $update = false; $plugins = sp_get_plugins(); if (!empty($plugins)) { $up = new stdClass(); foreach ($plugins as $file => $installed) { foreach ($xml->plugins->plugin as $latest) { if ($installed['Name'] == $latest->name) { if (version_compare($latest->version, $installed['Version'], '>') == 1) { $data->slug = $file; $data->new_version = (string) $latest->version; $data->url = 'http://simple-press.com'; $data->package = (string) $latest->archive . '&wpupdate=1'; $up->response[$file] = $data; $update = true; } } } } } if ($update) { set_site_transient('sp_update_plugins', $up); } else { delete_site_transient('sp_update_plugins'); } include_once SF_PLUGIN_DIR . '/admin/panel-themes/support/spa-themes-prepare.php'; $update = false; $themes = sp_get_themes(); if (!empty($themes)) { $up = new stdClass(); foreach ($themes as $file => $installed) { foreach ($xml->themes->theme as $latest) { if ($installed['Name'] == $latest->name) { if (version_compare($latest->version, $installed['Version'], '>') == 1) { $data = new stdClass(); $data->slug = $file; $data->stylesheet = $installed['Stylesheet']; $data->new_version = (string) $latest->version; $data->url = 'http://simple-press.com'; $data->package = (string) $latest->archive . '&wpupdate=1'; $up->response[$file] = $data; $update = true; } } } } } if ($update) { set_site_transient('sp_update_themes', $up); } else { delete_site_transient('sp_update_themes'); } } }
function spa_themes_mobile_form() { global $spPaths; ?> <script type="text/javascript"> jQuery(document).ready(function() { spjAjaxForm('sfmobiletheme', 'sfreloadmlist'); }); </script> <?php # get current theme $mobileTheme = sp_get_option('sp_mobile_theme'); if (!isset($mobileTheme['active'])) { $mobileTheme['active'] = false; } $ahahURL = SFHOMEURL . 'index.php?sp_ahah=themes-loader&sfnonce=' . wp_create_nonce('forum-ahah') . '&saveform=mobile'; ?> <form action="<?php echo $ahahURL; ?> " method="post" id="sfmobiletheme" name="sfmobiletheme"> <?php echo sp_create_nonce('forum-adminform_themes'); spa_paint_options_init(); spa_paint_open_tab(spa_text('Mobile Theme Support') . ' - ' . spa_text('Mobile Theme')); spa_paint_open_panel(); spa_paint_spacer(); echo '<div class="sfoptionerror">'; echo spa_text('Themes Folder') . ': <b>wp-content/' . $spPaths['themes'] . '</b>'; echo '</div>'; spa_paint_open_fieldset(spa_text('Mobile Support'), true, 'mobile-support'); spa_paint_checkbox(spa_text('Enable mobile theme support'), 'active', $mobileTheme['active']); spa_paint_close_fieldset(); spa_paint_close_panel(); spa_paint_tab_right_cell(); spa_paint_open_panel(); if ($mobileTheme['active']) { require_once ABSPATH . 'wp-admin/includes/template.php'; require_once ABSPATH . 'wp-admin/includes/theme.php'; spa_paint_open_fieldset(spa_text('Mobile Display Options'), true, 'mobile-display'); spa_paint_checkbox(spa_text('Use alternate WordPress template'), 'usetemplate', $mobileTheme['usetemplate']); spa_paint_select_start(spa_text('Alternate page template'), 'pagetemplate', 'pagetemplate'); echo '<option value="page.php">' . spa_text('Default Template') . '</option>'; page_template_dropdown($mobileTheme['pagetemplate']); spa_paint_select_end(); spa_paint_checkbox(spa_text('Remove Page Title Completely'), 'notitle', $mobileTheme['notitle']); spa_paint_close_fieldset(); } spa_paint_close_panel(); do_action('sph_themes_mobile_option_panel'); spa_paint_close_container(); ?> <div class="sfform-submit-bar"> <input type="submit" class="button-primary" id="saveit" name="saveit" value="<?php spa_etext('Update Mobile Component'); ?> " /> </div> <?php spa_paint_close_tab(); ?> </form> <div class="sfform-panel-spacer"></div> <?php if ($mobileTheme['active']) { # get themes $themes = sp_get_themes_list_data(); # get update version info $xml = sp_load_version_xml(); spa_paint_open_tab(spa_text('Available Themes') . ' - ' . spa_text('Select Simple:Press Mobile Theme'), true); spa_paint_open_panel(); spa_paint_open_fieldset(spa_text('Mobile Theme Management'), true, 'themes'); ?> <h3><?php echo spa_text('Current Mobile Theme'); ?> </h3> <div class="theme-browser rendered"> <div class="spThemeContainer"> <div id="current-theme" class="spTheme"> <h3 class="theme-name"><?php echo $themes[$mobileTheme['theme']]['Name']; ?> </h3> <img src="<?php echo SPTHEMEBASEURL . $mobileTheme['theme'] . '/' . $themes[$mobileTheme['theme']]['Screenshot']; ?> " alt="" /> <h4> <?php echo $themes[$mobileTheme['theme']]['Name'] . ' ' . $themes[$mobileTheme['theme']]['Version'] . ' ' . spa_text('by') . ' <a href="' . $themes[$mobileTheme['theme']]['AuthorURI'] . '" title="' . spa_text('Visit author homepage') . '">' . $themes[$mobileTheme['theme']]['Author'] . '</a>'; ?> </h4> <?php if (!empty($mobileTheme['parent'])) { if (file_exists(SPTHEMEBASEDIR . $mobileTheme['parent'])) { echo '<p class="theme-parent">'; echo spa_text('This theme is a child theme of ') . '<b>' . $mobileTheme['parent'] . '</b>'; echo '</p>'; } else { echo '<p class="theme-parent">'; echo '<b>' . spa_text('The specified parent theme') . " '" . $mobileTheme['parent'] . "' " . spa_text('does not exist') . '</b> '; echo '</p>'; } } ?> <p class="description" style="padding: 0;"> <?php echo $themes[$mobileTheme['theme']]['Description']; ?> </p> <?php $overlays = sp_get_overlays(SPTHEMEBASEDIR . $mobileTheme['theme'] . '/styles/overlays'); # pull in parent overlays if child theme if (!empty($mobileTheme['parent'])) { $parent_overlays = sp_get_overlays(SPTHEMEBASEDIR . $mobileTheme['parent'] . '/styles/overlays'); $overlays = array_merge($overlays, $parent_overlays); } if (!empty($overlays)) { ?> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('#sftheme-<?php echo esc_js($mobileTheme['theme']); ?> ').ajaxForm({ target: '#sfmsgspot', success: function() { jQuery('#sfreloadmlist').click(); jQuery('#sfmsgspot').fadeIn(); jQuery('#sfmsgspot').fadeOut(6000); } }); }); </script> <br> <?php $ahahURL = SFHOMEURL . 'index.php?sp_ahah=themes-loader&sfnonce=' . wp_create_nonce('forum-ahah') . '&saveform=mobile'; echo '<form action="' . $ahahURL . '" method="post" id="sftheme-' . esc_attr($mobileTheme['theme']) . '" name="sftheme-' . esc_attr($mobileTheme['theme']) . '">'; echo sp_create_nonce('forum-adminform_themes'); echo '<input type="hidden" name="active" value="' . $mobileTheme['active'] . '" />'; echo '<input type="hidden" name="theme" value="' . esc_attr($mobileTheme['theme']) . '" />'; echo '<input type="hidden" name="style" value="' . esc_attr($themes[$mobileTheme['theme']]['Stylesheet']) . '" />'; echo '<input type="hidden" name="parent" value="' . esc_attr($mobileTheme['parent']) . '" />'; $theme_colors = empty($themes[$mobileTheme['theme']]['Colors']) ? '' : explode(',', $themes[$mobileTheme['theme']]['Colors']); echo '<input type="hidden" name="default-color" value="' . esc_attr($overlays[0]) . '" />'; echo spa_text('Select Overlay') . ': '; echo '<select name="color-' . esc_attr($mobileTheme['theme']) . '">'; foreach ($overlays as $overlay) { $overlay = trim($overlay); $selected = $mobileTheme['color'] == $overlay ? ' selected="selected" ' : ''; echo '<option' . $selected . ' value="' . esc_attr($overlay) . '">' . esc_html($overlay) . '</option>'; } echo '</select> '; echo ' <input type="submit" class="button-secondary action" id="saveit-cur" name="saveit-cur" value="' . spa_text('Update Overlay') . '" />'; echo '</form>'; } # any upgrade for this theme? in multisite only main site can update if (is_main_site() && $xml) { foreach ($xml->themes->theme as $latest) { if ($themes[$mobileTheme['theme']]['Name'] == $latest->name) { if (version_compare($latest->version, $themes[$mobileTheme['theme']]['Version'], '>') == 1) { echo '<br />'; echo '<p style="padding: 0;">'; echo '<strong>' . spa_text('There is an update for the') . ' ' . $themes[$mobileTheme['theme']]['Name'] . ' ' . spa_text('theme') . '.</strong> '; echo spa_text('Version') . ' ' . $latest->version . ' ' . spa_text('is available') . '. '; echo spa_text('For details and to download please visit') . ' ' . SFPLUGHOME . ' ' . spa_text('or') . ' ' . spa_text('go to the') . ' '; echo '<a href="' . self_admin_url('update-core.php') . '" title="" target="_parent">' . spa_text('WordPress updates page') . '</a>'; echo '</p>'; } break; } } } ?> </div></div></div> <br class="clear" /> <h3><?php echo spa_text('Available Themes'); ?> </h3> <?php $numThemes = count($themes); if ($numThemes > 1) { ?> <div class="theme-browser rendered"> <div class="spThemeContainer"> <?php foreach ((array) $themes as $theme_file => $theme_data) { # skip cur theme if ($theme_file == $mobileTheme['theme']) { continue; } $theme_desc = $theme_data['Description']; $theme_name = $theme_data['Name']; $theme_version = $theme_data['Version']; $theme_author = $theme_data['Author']; $theme_uri = $theme_data['AuthorURI']; $theme_style = $theme_data['Stylesheet']; $theme_image = SPTHEMEBASEURL . $theme_file . '/' . $theme_data['Screenshot']; $theme_overlays = sp_get_overlays(SPTHEMEBASEDIR . $theme_file . '/styles/overlays'); # pull in parent overlays if child theme if (!empty($theme_data['Parent'])) { $parent_overlays = sp_get_overlays(SPTHEMEBASEDIR . $theme_data['Parent'] . '/styles/overlays'); $theme_overlays = array_merge($theme_overlays, $parent_overlays); } ?> <div class="spTheme"> <h3 class="theme-name"><?php echo $theme_name; ?> </h3> <img alt="" src="<?php echo $theme_image; ?> " /> <h4> <?php echo $theme_name . ' ' . $theme_version . ' ' . spa_text('by') . ' <a href="' . $theme_uri . '" title="' . spa_text('Visit author homepage') . '">' . $theme_author . '</a>'; ?> </h4> <?php if (!empty($theme_data['Parent'])) { if (file_exists(SPTHEMEBASEDIR . $theme_data['Parent'])) { echo '<p class="theme-parent">'; echo spa_text('This theme is a child theme of ') . '<b>' . $theme_data['Parent'] . '</b>'; echo '</p>'; } else { echo '<p class="theme-parent">'; echo '<b>' . spa_text('The specified parent theme') . " '" . $theme_data['Parent'] . "' " . spa_text('does not exist') . '</b> '; echo '</p>'; } } ?> <p class="description" style="padding: 0;"> <?php echo $theme_desc; ?> </p> <br> <div class="action-links"> <script type="text/javascript"> jQuery(document).ready(function() { spjAjaxForm('sftheme-<?php echo esc_js($theme_file); ?> ', 'sfreloadmlist'); }); </script> <?php $ahahURL = SFHOMEURL . 'index.php?sp_ahah=themes-loader&sfnonce=' . wp_create_nonce('forum-ahah') . '&saveform=mobile'; ?> <form action="<?php echo $ahahURL; ?> " method="post" id="sftheme-<?php echo esc_attr($theme_file); ?> " name="sftheme-<?php echo esc_attr($theme_file); ?> "> <?php echo sp_create_nonce('forum-adminform_themes'); ?> <input type="hidden" name="active" value="<?php echo $mobileTheme['active']; ?> " /> <input type="hidden" name="theme" value="<?php echo esc_attr($theme_file); ?> " /> <input type="hidden" name="style" value="<?php echo esc_attr($theme_style); ?> " /> <input type="hidden" name="parent" value="<?php echo esc_attr($theme_data['Parent']); ?> " /> <?php $defOverlay = !empty($theme_overlays) ? esc_attr($theme_overlays[0]) : 0; ?> <input type="hidden" name="default-color" value="<?php echo esc_attr($defOverlay); ?> " /> <?php if ($theme_overlays) { echo spa_text('Select Overlay') . ': '; echo ' <select name="color-' . esc_attr($theme_file) . '" style="margin-bottom:5px;">'; foreach ($theme_overlays as $theme_overlay) { $theme_overlay = trim($theme_overlay); $selected = $theme_overlays[0] == $theme_overlay ? ' selected="selected" ' : ''; echo '<option' . $selected . ' value="' . esc_attr($theme_overlay) . '">' . esc_html($theme_overlay) . '</option>'; } echo '</select> '; echo '<div class="clearboth"></div>'; } ?> <input type="submit" class="button-secondary action" id="saveit-<?php echo esc_attr($theme_file); ?> " name="saveit-<?php echo esc_attr($theme_file); ?> " value="<?php echo spa_etext('Activate Mobile Theme'); ?> " /> </form> </div> <?php # any upgrade for this theme? if ($xml) { foreach ($xml->themes->theme as $latest) { if ($theme_data['Name'] == $latest->name) { if (version_compare($latest->version, $theme_data['Version'], '>') == 1) { echo '<br />'; echo '<div class="plugin-update-tr"><div class="update-message" style="background-color:#fcf3ef;margin-left:10px;">'; echo '<strong>' . spa_text('There is an update for the') . ' ' . $theme_data['Name'] . ' ' . spa_text('theme') . '.</strong> '; echo spa_text('Version') . ' ' . $latest->version . ' ' . spa_text('is available') . '. '; echo spa_text('For details and to download please visit') . ' ' . SFPLUGHOME . ' ' . spa_text('or') . ' ' . spa_text('go to the') . ' '; echo '<a href="' . self_admin_url('update-core.php') . '" title="" target="_parent">' . spa_text('WordPress updates page') . '</a>'; echo '</div></div>'; } break; } } } echo '</div>'; } echo '</div>'; echo '</div>'; } else { echo spa_text('No other available themes found'); } do_action('sph_themes_mobile_list_panel'); spa_paint_close_fieldset(); spa_paint_close_panel(); spa_paint_close_container(); spa_paint_close_tab(); } }
function sp_version_checks() { global $wp_version, $wpdb; $message = ''; $testtable = true; $logo = '<div class="error"><img src="' . SFCOMMONIMAGES . 'sp-full-logo.png" alt="" title="" /><br /><hr />'; $xml = sp_load_version_xml(); if ($xml) { # WordPress version check $wp_required = (string) $xml->core->requires; if (sp_version_compare($wp_required, $wp_version) == false) { $message .= $logo; $message .= '<h3>' . sprintf(spa_text('%s Version %s'), 'WordPress', $wp_version) . '</h3>'; $message .= '<p>' . sprintf(spa_text('Your version of %s is not supported by %s %s'), 'WordPress', 'Simple:Press', SPVERSION) . '<br />'; $message .= sprintf(spa_text('%s version %s or above is required'), 'WordPress', $wp_required) . '</p><br />'; $logo = '<hr />'; } # MySQL Check $mysql_required = (string) $xml->core->mysql_ver; if (sp_version_compare($mysql_required, $wpdb->db_version()) == false) { $message .= $logo; $message .= '<h3>' . sprintf(spa_text('%s Version %s'), 'MySQL', $wpdb->db_version()) . '</h3>'; $message .= '<p>' . sprintf(spa_text('Your version of %s is not supported by %s %s'), 'MySQL', 'Simple:Press', SPVERSION) . '<br />'; $message .= sprintf(spa_text('%s version %s or above is required'), 'MySQL', $mysql_required) . '</p><br />'; $logo = '<hr />'; $testtable = false; } # PHP Check $php_required = (string) $xml->core->php_ver; if (sp_version_compare($php_required, phpversion()) == false) { $message .= $logo; $message .= '<h3>' . sprintf(spa_text('%s Version %s'), 'PHP', phpversion()) . '</h3>'; $message .= '<p>' . sprintf(spa_text('Your version of %s is not supported by %s %s'), 'PHP', 'Simple:Press', SPVERSION) . '<br />'; $message .= sprintf(spa_text('%s version %s or above is required'), 'PHP', $php_required) . '</p><br />'; $logo = '<hr />'; } # test we can create database tables if ($testtable) { if (sp_test_table_create() == false) { $message .= $logo; $message .= '<h3>' . spa_text('Database Problem') . '</h3>'; $message .= '<p>' . sprintf(spa_text('%s can not Create Tables in your database'), 'Simple:Press') . '</p><br />'; } } } else { $message .= '<h3>' . spa_text('Unable to communicate with SP servers for version requirements. Please try again in few minutes.') . '</h3>'; } if ($message) { $message .= '</div>'; } return $message; }
function sp_update_check_sp_themes() { $xml = sp_load_version_xml(); if ($xml) { include_once SF_PLUGIN_DIR . '/admin/panel-themes/support/spa-themes-prepare.php'; $themes = sp_get_themes(); if (empty($themes)) { return; } $up = new stdClass(); $update = false; $header = true; foreach ($themes as $file => $installed) { foreach ($xml->themes->theme as $latest) { if ($installed['Name'] == $latest->name) { if (version_compare($latest->version, $installed['Version'], '>') == 1) { if ($header) { $form_action = 'update-core.php?action=do-sp-theme-upgrade'; ?> <h3><?php spa_etext('Simple:Press Themes'); ?> </h3> <p><?php spa_etext('The following themes have new versions available. Check the ones you want to update and then click Update Themes.'); ?> </p> <p><?php echo '<b>' . spa_text('Please Note:') . '</b> ' . spa_text('Any customizations you have made to theme files will be lost.'); ?> </p> <form method="post" action="<?php echo $form_action; ?> " name="upgrade-themes" class="upgrade"> <?php wp_nonce_field('upgrade-core'); ?> <p><input id="upgrade-themes" class="button" type="submit" value="<?php spa_etext('Update SP Themes'); ?> " name="upgrade" /></p> <table class="widefat" cellspacing="0" id="update-themes-table"> <thead> <tr> <th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></th> <th scope="col" class="manage-column"><label for="themes-select-all"><?php spa_etext('Select All'); ?> </label></th> </tr> </thead> <tfoot> <tr> <th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></th> <th scope="col" class="manage-column"><label for="themes-select-all-2"><?php spa_etext('Select All'); ?> </label></th> </tr> </tfoot> <tbody class="plugins"> <?php $header = false; } $screenshot = SPTHEMEBASEURL . $file . '/' . $installed['Screenshot']; echo "\n\t\t\t\t\t\t\t<tr class='active'>\n\t\t\t\t\t\t\t<th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($file) . "' /></th>\n\t\t\t\t\t\t\t<td class='plugin-title'><img src='{$screenshot}' width='64' height='64' style='float:left; padding: 5px' /><strong>{$installed['Name']}</strong>" . sprintf(spa_text('You have version %1$s installed. Update to %2$s. Requires SP Version %3$s.'), $installed['Version'], $latest->version, $latest->requires) . "</td>\n\t\t\t\t\t\t\t</tr>"; $data = new stdClass(); $data->slug = $file; $data->stylesheet = $installed['Stylesheet']; $data->new_version = (string) $latest->version; $data->url = 'http://simple-press.com'; $data->package = (string) $latest->archive . '&wpupdate=1'; $up->response[$file] = $data; $update = true; } } } } # any themes to update? if ($update) { set_site_transient('sp_update_themes', $up); } else { delete_site_transient('sp_update_themes'); } if (!$header) { ?> </tbody> </table> <p><input id="upgrade-themes-2" class="button" type="submit" value="<?php spa_etext('Update SP Themes'); ?> " name="upgrade" /></p> </form> <?php } else { echo '<h3>' . spa_text('Simple:Press Themes') . '</h3>'; echo '<p>' . spa_text('Your SP themes are all up to date') . '</p>'; } } }
function spa_plugins_list_form() { global $spPaths; ?> <script type="text/javascript"> jQuery(document).ready(function() { spjAjaxForm('sppluginsform', 'sfreloadpl'); /* wp check all logic */ jQuery('thead, tfoot').find('.check-column :checkbox').click( function(e) { var c = jQuery(this).prop('checked'), kbtoggle = 'undefined' == typeof toggleWithKeyboard ? false : toggleWithKeyboard, toggle = e.shiftKey || kbtoggle; jQuery(this).closest( 'table' ).children( 'tbody' ).filter(':visible') .children().children('.check-column').find(':checkbox') .prop('checked', function() { if ( jQuery(this).is(':hidden') ) return false; if ( toggle ) return jQuery(this).prop( 'checked' ); else if (c) return true; return false; }); jQuery(this).closest('table').children('thead, tfoot').filter(':visible') .children().children('.check-column').find(':checkbox') .prop('checked', function() { if ( toggle ) return false; else if (c) return true; return false; }); }); }); </script> <?php # get plugins $plugins = spa_get_plugins_list_data(); # get update version info $xml = sp_load_version_xml(); # check active plugins $invalid = sp_validate_active_plugins(); if (!empty($invalid)) { foreach ($invalid as $plugin_file => $error) { echo '<div id="message" class="error"><p>' . sprintf(spa_text('The plugin %1$s has been deactivated due to error: %2$s'), esc_html($plugin_file), $error->get_error_message()) . '</p></div>'; } } $ahahURL = SFHOMEURL . 'index.php?sp_ahah=plugins-loader&sfnonce=' . wp_create_nonce('forum-ahah') . '&saveform=list'; $msg = esc_js(spa_text('Are you sure you want to delete the selected Simple Press plugins?')); ?> <form action="<?php echo $ahahURL; ?> " method="post" id="sppluginsform" name="sppluginsform" onsubmit="javascript: if (ActionType.options[ActionType.selectedIndex].value == 'delete-selected' || ActionType2.options[ActionType2.selectedIndex].value == 'delete-selected') {if (confirm('<?php echo $msg; ?> ')) {return true;} else {return false;}} else {return true;}"> <?php echo sp_create_nonce('forum-adminform_plugins'); spa_paint_options_init(); spa_paint_open_tab(spa_text('Available Plugins') . ' - ' . spa_text('Install Simple:Press Plugins'), true); spa_paint_open_panel(); spa_paint_spacer(); echo '<div class="sfoptionerror">'; echo spa_text('Plugins Folder') . ': <b>' . realpath(SF_STORE_DIR . '/' . $spPaths['plugins']) . '</b>'; echo '</div>'; spa_paint_open_fieldset(spa_text('Plugin Management'), true, 'plugins'); ?> <div class="tablenav top"> <div class="alignleft actions"> <select id="ActionType" name="action"> <option selected="selected" value="-1"><?php echo spa_text('Bulk Actions'); ?> </option> <option value="activate-selected"><?php echo spa_text('Activate'); ?> </option> <option value="deactivate-selected"><?php echo spa_text('Deactivate'); ?> </option> <?php if (!is_multisite() || is_super_admin()) { ?> <option value="delete-selected"><?php echo spa_text('Delete'); ?> </option><?php } ?> </select> <input id="doaction" class="button-secondary action" type="submit" value="<?php echo spa_text('Apply'); ?> " /> </div> <div class="tablenav-pages one-page"> <span class="displaying-num"><?php echo count($plugins) . ' ' . spa_text('plugins'); ?> </span> </div> </div> <table class="wp-list-table widefat plugins"> <thead> <tr> <td id='cb' class='manage-column column-cb check-column'> <input type="checkbox" name="cbhead" id="cbhead" /> <label class="wp-core-ui" for='cbhead'> </label> </td> <th class='manage-column check-column'></th> <th class='manage-column column-name column-primary'> <?php spa_etext('Plugin'); ?> </th> <th class='manage-column column-description'> <?php spa_etext('Description'); ?> </th> </tr> </thead> <tbody class="the-list"> <?php if (empty($plugins)) { echo '<tr><td colspan="4">' . spa_text('No plugins found.') . '</td></tr>'; } $disabled = ''; foreach ((array) $plugins as $plugin_file => $plugin_data) { # check for valid folder name $path = explode('/', $plugin_file); $bad = is_numeric(substr($path[0], -1)); $is_active = sp_is_plugin_active($plugin_file); if ($is_active) { $url = SFADMINPLUGINS . '&action=deactivate&plugin=' . esc_attr($plugin_file) . '&title=' . urlencode(esc_attr($plugin_data['Name'])) . '&sfnonce=' . wp_create_nonce('forum-adminform_plugins'); $actionlink = "<a href='{$url}' title='" . spa_text('Deactivate this Plugin') . "'>" . spa_text('Deactivate') . '</a>'; $actionlink = apply_filters('sph_plugins_active_buttons', $actionlink, $plugin_file); $actionlink .= sp_paint_plugin_tip($plugin_data['Name'], $plugin_file); $rowClass = 'active'; $icon = '<img src="' . SFADMINIMAGES . 'sp_Yes.png" title="' . spa_text('Plugin activated') . '" alt="" style="vertical-align:middle;" />'; } else { if ($bad) { $rowClass = 'inactive spWarningBG'; $actionlink = ''; $icon = '<img src="' . SFADMINIMAGES . 'sp_NoWrite.png" title="' . spa_text('Warning') . '" alt="" style="vertical-align:middle;" />'; $disabled = ' disabled="disabled" '; } else { $url = SFADMINPLUGINS . '&action=activate&plugin=' . esc_attr($plugin_file) . '&title=' . urlencode(esc_attr($plugin_data['Name'])) . '&sfnonce=' . wp_create_nonce('forum-adminform_plugins'); $actionlink = "<a href='{$url}' title='" . spa_text('Activate this Plugin') . "'>" . spa_text('Activate') . "</a>"; $url = SFADMINPLUGINS . '&action=delete&plugin=' . esc_attr($plugin_file) . '&title=' . urlencode(esc_attr($plugin_data['Name'])) . '&sfnonce=' . wp_create_nonce('forum-adminform_plugins'); $msg = esc_js(spa_text('Are you sure you want to delete this Simple Press plugin?')); if (!is_multisite() || is_super_admin()) { $actionlink .= ' | <a href="javascript: if (confirm(\'' . $msg . '\')) {window.location=\'' . $url . '\';}" title="' . spa_text('Delete this Plugin') . '">' . spa_text('Delete') . '</a>'; } $actionlink = apply_filters('sph_plugins_inactive_buttons', $actionlink, $plugin_file); $rowClass = 'inactive'; $icon = '<img src="' . SFADMINIMAGES . 'sp_No.png" title="' . spa_text('Plugin not activated') . '" alt="" style="vertical-align: middle;" />'; $disabled = ''; } } $description = $plugin_data['Description']; $plugin_name = $plugin_data['Name']; ?> <tr class='<?php echo $rowClass; ?> '> <th class='manage-column column-cb check-column' scope='row'> <?php $thisId = 'checkbox_' . rand(1, 9999999999); ?> <input id="<?php echo $thisId; ?> " type="checkbox" value="<?php echo $plugin_file; ?> " name="checked[]" <?php echo $disabled; ?> /> <label for="<?php echo $thisId; ?> "> </label> </th> <td class='manage-column check-column'> <?php echo $icon; ?> </td> <td class='manage-column column-name column-primary'> <strong><?php echo esc_html($plugin_name); ?> </strong> <div class="row-actions-visible"> <span><?php echo str_replace(' ', ' | ', $actionlink); ?> </span> </div> </td> <td class='manage-column column-description'> <div class='manage-column column-description'> <?php echo $description; ?> </div> <div class='<?php echo $rowClass; ?> second plugin-version-author-uri'> <?php $plugin_meta = array(); if (!empty($plugin_data['Version'])) { $plugin_meta[] = sprintf(spa_text('Version %s'), $plugin_data['Version']); } if (!empty($plugin_data['Author'])) { $author = $plugin_data['Author']; if (!empty($plugin_data['AuthorURI'])) { $author = '<a href="' . esc_url($plugin_data['AuthorURI']) . '" title="' . spa_text('Visit author homepage') . '">' . esc_html($plugin_data['Author']) . '</a>'; } $plugin_meta[] = sprintf(spa_text('By %s'), $author); } if (!empty($plugin_data['PluginURI'])) { $plugin_meta[] = '<a href="' . esc_url($plugin_data['PluginURI']) . '" title="' . spa_text('Visit plugin site') . '">' . esc_html(spa_text('Visit plugin site')) . '</a>'; } echo implode(' | ', $plugin_meta); ?> </div> </td> </tr> <?php # is it bad? if ($bad) { preg_match('/-?\\s*\\d+$/', $path[0], $fix); $suggest = str_replace($fix[0], '', $path[0]); ?> <tr class='<?php echo $rowClass; ?> '> <td colspan="4"> <div class="sfoptionerror"> <?php echo sprintf(spa_text('The folder name of this plugin has become corrupted - probably due to multiple downloads. Please remove the %s at the end of the folder name. The proper folder name should be %s'), "<strong>{$fix['0']}</strong>", "<strong>{$suggest}</strong>"); ?> </div> </td> </tr> <?php } # any upgrade for this plugin? in multisite only main site can update if (is_main_site() && $xml) { foreach ($xml->plugins->plugin as $latest) { if ($plugin_data['Name'] == $latest->name) { if (version_compare($latest->version, $plugin_data['Version'], '>') == 1) { ?> <tr class="plugin-update-tr"> <td class="plugin-update colspanchange" colspan="3"> <div class="update-message"> <?php echo spa_text('There is an update for the') . ' ' . $plugin_data['Name'] . ' ' . spa_text('plugin') . '. '; ?> <?php echo spa_text('Version') . ' ' . $latest->version . ' ' . spa_text('is available') . '. '; ?> <?php echo spa_text('For details and to download please visit') . ' ' . SFPLUGHOME . ' ' . spa_text('or') . ' ' . spa_text('go to the') . ' '; ?> <?php echo '<a href="' . self_admin_url('update-core.php') . '" title="" target="_parent">' . spa_text('WordPress updates page') . '</a>'; ?> </div> </td> </tr> <?php } break; } } } } do_action('sph_plugins_list_panel'); ?> </tbody> <tfoot> <tr> <td class='manage-column column-cb check-column'> <input type="checkbox" name="cbfoot" id="cbfoot" /> <label class="wp-core-ui" for='cbfoot'> </label> </td> <th class='manage-column check-column'></th> <th class='manage-column column-name column-primary'> <?php spa_etext('Plugin'); ?> </th> <th class='manage-column column-description'> <?php spa_etext('Description'); ?> </th> </tr> </tfoot> </table> <div class="tablenav bottom"> <div class="alignleft actions"> <select id="ActionType2" name="action2"> <option selected="selected" value="-1"><?php echo spa_text('Bulk Actions'); ?> </option> <option value="activate-selected"><?php echo spa_text('Activate'); ?> </option> <option value="deactivate-selected"><?php echo spa_text('Deactivate'); ?> </option> <?php if (!is_multisite() || is_super_admin()) { ?> <option value="delete-selected"><?php echo spa_text('Delete'); ?> </option><?php } ?> </select> <input id="doaction2" class="button-secondary action" type="submit" value="<?php echo spa_text('Apply'); ?> " name="" /> </div> <div class="tablenav-pages one-page"> <span class="displaying-num"><?php echo count($plugins) . ' ' . spa_text('plugins'); ?> </span> </div> </div> <?php spa_paint_close_fieldset(); spa_paint_close_panel(); spa_paint_close_container(); ?> <div class="sfform-panel-spacer"></div> <?php spa_paint_close_tab(); ?> </form> <?php }