function woo_framework_version_checker($local_version, $check_if_critical = false) { $data = array('is_update' => false, 'version' => '1.0.0', 'status' => 'none'); if (!$local_version) { return $data; } $version_data = woo_get_fw_version('', $check_if_critical); $check = version_compare($version_data['version'], $local_version); // Returns 1 if there is an update available. if ($check == 1) { $data['is_update'] = true; $data['version'] = $version_data['version']; $data['is_critical'] = $version_data['is_critical']; } return $data; }
function woothemes_framework_update_page() { $update_url = 'http://www.woothemes.com/u/test-file.zip'; $method = get_filesystem_method(); ?> <div class="wrap themes-page"> <h2>Framework Update</h2> <?php echo $method; ?> <form method="post" enctype="multipart/form-data" id="wooform" action="<?php echo admin_url('admin.php?page=woothemes_framework_update'); ?> "> <?php wp_nonce_field('update-options'); ?> <p>The aim of this updater is to update the "functions" folder of your theme with the latest framework archive from the WooThemes.com server.</p> <p><strong>This feature is still in beta mode</strong> so it's safe to use, and won't do any overwriting of any important files. At this point in time it will only (is successful) add a "test-file.txt" to your theme's functions folder. Test it out and see if it works.</p> <p>Latest framework: <code><?php echo $update_url; ?> </code></p> <p>→ <strong>Your version:</strong> <?php echo get_option('woo_framework_version'); ?> </p> <p>→ <strong>Current Version:</strong> <?php woo_get_fw_version(); ?> </p> <input type="hidden" name="update_url" value="<?php echo $update_url; ?> " /> <input type="submit" value="Update Framework" /> <input type="hidden" name="woo_update_save" value="save" /> </form> </div> <?php }
function woothemes_framework_update_page() { $method = get_filesystem_method(); $to = ABSPATH . 'wp-content/themes/' . get_option('template') . "/functions/"; if (isset($_POST['password'])) { $cred = $_POST; $filesystem = WP_Filesystem($cred); } elseif (isset($_POST['woo_ftp_cred'])) { $cred = unserialize(base64_decode($_POST['woo_ftp_cred'])); $filesystem = WP_Filesystem($cred); } else { $filesystem = WP_Filesystem(); } $url = admin_url('admin.php?page=woothemes_framework_update'); ?> <div class="wrap themes-page"> <?php if ($filesystem == false) { request_filesystem_credentials($url); } else { ?> <h2>Framework Update</h2> <span style="display:none"><?php echo $method; ?> </span> <form method="post" enctype="multipart/form-data" id="wooform" action="<?php /* echo $url; */ ?> "> <?php wp_nonce_field('update-options'); ?> <p>Welcome to the WooThemes Framework Updater. This updater will collect a file from the WooThemes.com server, download and extract the files to your current theme's functions folder. </p> <?php $localversion = get_option('woo_framework_version'); $remoteversion = woo_get_fw_version(); ?> <p>→ <strong>Your version:</strong> <?php echo $localversion; ?> </p> <p>→ <strong>Current Version:</strong> <?php echo $remoteversion; ?> </p> <?php $localversion = trim(str_replace('.', '', $localversion)); $remoteversion = trim(str_replace('.', '', $remoteversion)); if (strlen($localversion) == 2) { $localversion = $localversion . '0'; } if (strlen($remoteversion) == 2) { $remoteversion = $remoteversion . '0'; } if ($localversion < $remoteversion) { ?> <input type="submit" value="Update Framework" /> <?php } else { echo '<span style="background:#EFE577">No upgrade needed. You are already running the latest available version.</span>'; } ?> <input type="hidden" name="woo_update_save" value="save" /> <input type="hidden" name="woo_ftp_cred" value="<?php echo base64_encode(serialize($_POST)); ?> " /> </form> <?php } ?> </div> <?php }
function woothemes_timthumb_update_page() { // Setup data $timthumb_update = get_option('woo_timthumb_update'); $url = admin_url('admin.php?page=woothemes_framework_update'); // Do the update if (isset($_POST['woo_update_save'])) { // Read in the old file $filename = locate_template('thumb.php'); // If File exists if ($filename != '') { // Call function test $file_read = woo_check_if_thumbs_are_equal($filename); $file_open = true; $file_write = false; // File was readable if ($file_read) { // Open file $file = fopen($filename, "w") or $file_open = false; // File opened successfully if ($file_open) { // New File Contents $new_file_contents = woo_thumb_new_contents(); $fwrite = fwrite($file, $new_file_contents); if ($fwrite === false) { // Write Fail $file_write = false; } else { // Write Success $file_write = true; } // End If Statement fclose($file); } // End If Statement if ($file_open && $file_write) { update_option('woo_timthumb_update', 'true'); } // End If Statement } else { echo 'An error occurred while reading your current thumb.php'; } // End If Statement } else { echo 'File does not exist.'; } // End If Statement } // Get the setting for update $timthumb_update = get_option('woo_timthumb_update'); ?> <div class="wrap themes-page"> <?php $localversion = get_option('woo_framework_version'); $remoteversion = woo_get_fw_version(); // Test if new version $upd = false; $loc = explode('.', $localversion); $rem = explode('.', $remoteversion); if ($loc[0] < $rem[0]) { $upd = true; } elseif ($loc[1] < $rem[1]) { $upd = true; } elseif ($loc[2] < $rem[2]) { $upd = true; } ?> <div class="icon32" id="icon-tools"><br></div> <h2>TimThumb Update</h2> <span style="display:none"><?php echo $method; ?> </span> <form method="post" enctype="multipart/form-data" id="wooform" action="<?php /* echo $url; */ ?> "> <?php if ($upd || $timthumb_update == '') { ?> <?php wp_nonce_field('update-options'); ?> <h3>A new version of TimThumb is available.</h3> <p>This updater will remove the old version of TimThumb (thumb.php) in your theme folder, and use the new TimThumb in the WooFramework.</p> <input type="submit" class="button" value="Update Timthumb" /> <?php } elseif ($file_open && $file_write) { ?> <h3>Thank you for updating your TimThumb. This section will now disable itself.</h3> <?php } else { ?> <h3>Your TimThumb has been updated already.</h3> <?php } ?> <input type="hidden" name="woo_update_save" value="save" /> </form> </div> <?php }
function woothemes_framework_update_page() { $method = get_filesystem_method(); $to = ABSPATH . 'wp-content/themes/' . get_option('template') . "/functions/"; if (isset($_POST['password'])) { $cred = $_POST; $filesystem = WP_Filesystem($cred); } elseif (isset($_POST['woo_ftp_cred'])) { $cred = unserialize(base64_decode($_POST['woo_ftp_cred'])); $filesystem = WP_Filesystem($cred); } else { $filesystem = WP_Filesystem(); } $url = admin_url('admin.php?page=woothemes_framework_update'); ?> <div class="wrap themes-page"> <?php if ($filesystem == false) { request_filesystem_credentials($url); } else { ?> <?php $localversion = get_option('woo_framework_version'); $remoteversion = woo_get_fw_version(); // Test if new version $upd = false; $loc = explode('.', $localversion); $rem = explode('.', $remoteversion); if ($loc[0] < $rem[0]) { $upd = true; } elseif ($loc[1] < $rem[1]) { $upd = true; } elseif ($loc[2] < $rem[2]) { $upd = true; } ?> <div class="icon32" id="icon-tools"><br></div> <h2>Framework Update</h2> <span style="display:none"><?php echo $method; ?> </span> <form method="post" enctype="multipart/form-data" id="wooform" action="<?php /* echo $url; */ ?> "> <?php if ($upd) { ?> <?php wp_nonce_field('update-options'); ?> <h3>A new version of WooFramework is available.</h3> <p>This updater will collect a file from the WooThemes.com server. It will download and extract the files to your current theme's functions folder. </p> <p>We recommend backing up your theme files before updating. Only upgrade the WooFramework if necessary.</p> <p>→ <strong>Your version:</strong> <?php echo $localversion; ?> </p> <p>→ <strong>Current Version:</strong> <?php echo $remoteversion; ?> </p> <input type="submit" class="button" value="Update Framework" /> <?php } else { ?> <h3>You have the latest version of WooFramework</h3> <p>→ <strong>Your version:</strong> <?php echo $localversion; ?> </p> <?php } ?> <input type="hidden" name="woo_update_save" value="save" /> <input type="hidden" name="woo_ftp_cred" value="<?php echo base64_encode(serialize($_POST)); ?> " /> </form> <?php } ?> </div> <?php }