Пример #1
0
/**
 * Admin Messages
 *
 * @since 0.9.0
 * @global $wpstg_options Array of all the WPSTG Options
 * @return void
 */
function wpstg_admin_messages()
{
    global $wpstg_options;
    if (wpstg_is_admin_page() && !wp_is_writable(wpstg_get_upload_dir())) {
        echo '<div class="error">';
        echo '<p><strong>WP Staging File Permission error: </strong>' . wpstg_get_upload_dir() . ' is not write and/or readable. <br> Check if the folder ' . wpstg_get_upload_dir() . ' exists! File permissions should be chmod 755 or 777.</p>';
        echo '</div>';
    }
    $path = wpstg_get_upload_dir() . '/clone_details.json';
    if (wpstg_is_admin_page() && !wpstg_clonedetailsjson_exists() || !is_readable($path)) {
        echo '<div class="error">';
        echo '<p><strong>WP Staging File Permission error: </strong>' . $path . ' is not write and/or readable. <br> Check if the file ' . $path . ' exists! File permissions should be chmod 644 or 777.</p>';
        echo '</div>';
    }
    $path = wpstg_get_upload_dir() . '/remaining_files.json';
    if (wpstg_is_admin_page() && !wpstg_remainingjson_exists() || !is_readable($path)) {
        echo '<div class="error">';
        echo '<p><strong>WP Staging File Permission error: </strong>' . $path . ' is not write and/or readable . <br> Check if the file ' . $path . ' exists! File permissions should be chmod 644 or 777.</p>';
        echo '</div>';
    }
    if (wpstg_is_admin_page() && version_compare(WPSTG_WP_COMPATIBLE, get_bloginfo('version'), '>')) {
        echo '<div class="error"><p>';
        echo sprintf(__('You are using an outdated version of WP Staging which has not been tested with your WordPress version %2$s.<br> 
            As WP Staging is using crucial db and file functions it\'s important that you are using a WP Staging version<br> 
            which has been verified to be working with your WordPress version. You risk unexpected results up to data lose if you do not so.
            <p>Please look at <a href="%1$s" target="_blank">%s</a> for the latest WP Staging version.', 'wpstg'), 'https://wordpress.org/plugins/wp-staging/', get_bloginfo('version'));
        echo '</p></div>';
    }
    echo wpstg_show_beta_message();
    $install_date = get_option('wpstg_installDate');
    $display_date = date('Y-m-d h:i:s');
    $datetime1 = new DateTime($install_date);
    $datetime2 = new DateTime($display_date);
    $diff_intrval = round(($datetime2->format('U') - $datetime1->format('U')) / (60 * 60 * 24));
    if ($diff_intrval >= 7 && get_option('wpstg_RatingDiv') == "no") {
        echo '<div class="wpstg_fivestar updated" style="box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);">
    	<p>Awesome, you\'ve been using <strong>WP Staging </strong> for more than 1 week. May we ask you to give it a <strong>5-star</strong> rating on Wordpress? 
        <p><strong>Regards,<br>René Hermenau</strong>
        <ul>
            <li><a href="https://wordpress.org/support/view/plugin-reviews/wp-staging" class="thankyou" target="_new" title="Ok, you deserved it" style="font-weight:bold;">Ok, you deserved it</a></li>
            <li><a href="javascript:void(0);" class="wpstg_hide_rating" title="I already did" style="font-weight:bold;">I already did</a></li>
            <li><a href="javascript:void(0);" class="wpstg_hide_rating" title="No, not good enough" style="font-weight:bold;">No, not good enough</a></li>
        </ul>
    </div>
    <script>
    jQuery( document ).ready(function( $ ) {
        jQuery(\'.wpstg_hide_rating\').click(function(){
                 var data={\'action\':\'wpstg_hide_rating\'}
                jQuery.ajax({
                    url: "' . admin_url('admin-ajax.php') . '",
                    type: "post",
                    data: data,
                    dataType: "json",
                    async: !0,
                    success: function(e) {
                        if (e=="success") {
                           jQuery(\'.wpstg_fivestar\').slideUp(\'slow\');
                        }
                    }
                });
        })
        jQuery(\'.wpstg_hide_beta\').click(function(){
                 var data={\'action\':\'wpstg_hide_beta\'}
                jQuery.ajax({
                    url: "' . admin_url('admin-ajax.php') . '",
                    type: "post",
                    data: data,
                    dataType: "json",
                    async: !0,
                    success: function(e) {
                        if (e=="success") {
                           jQuery(\'.wpstg_beta_notice\').slideUp(\'slow\');
                        }
                    }
                });
        })
    });
    </script>
    ';
    }
}
/** 
 * Save global clone details options
 * and create clone_details.json
 * 
 * @return void
 */
function wpstg_save_options()
{
    global $wpstg_clone_details;
    $path = wpstg_get_upload_dir();
    if (wp_is_writable($path)) {
        $file = 'clone_details.json';
        file_put_contents($path . '/' . $file, json_encode($wpstg_clone_details));
    } else {
        wpstg_log($path . '/' . $file . ' is not writeable! ');
    }
}
Пример #3
0
/** 
 * Create json cloning_details.json after activation of the plugin
 * 
 * @return bool
 */
function wpstg_create_clonedetails_files()
{
    $path = wpstg_get_upload_dir();
    if (wp_is_writable($path)) {
        $file = 'clone_details.json';
        file_put_contents($path . '/' . $file, null);
    } else {
        WPSTG()->logger->info($path . '/' . $file . ' is not writeable! ');
    }
}
/**
 * Creates blank index.php and .htaccess files
 * Creates /wp-content/uploads/wp-staging subfolder
 *
 * This function runs approximately once per month in order to ensure all folders
 * have their necessary protection files
 *
 * @since 1.1.0
 *
 * @param bool $force
 */
function wpstg_create_protection_files($force = false)
{
    if (false === get_transient('wpstg_check_protection_files') || $force) {
        $upload_path = wpstg_get_upload_dir();
        // Make sure the /wpstg folder is created
        wp_mkdir_p($upload_path);
        // Top level .htaccess file
        $rules = wpstg_get_htaccess_rules();
        if (wpstg_htaccess_exists()) {
            $contents = @file_get_contents($upload_path . '/.htaccess');
            if ($contents !== $rules || !$contents) {
                // Update the .htaccess rules if they don't match
                @file_put_contents($upload_path . '/.htaccess', $rules);
            }
        } elseif (wp_is_writable($upload_path)) {
            // Create the file if it doesn't exist
            @file_put_contents($upload_path . '/.htaccess', $rules);
        }
        // Top level blank index.php
        if (!file_exists($upload_path . '/index.php') && wp_is_writable($upload_path)) {
            @file_put_contents($upload_path . '/index.php', '<?php' . PHP_EOL . '// Silence is golden.');
        }
        // Now place index.php files in all sub folders
        $folders = wpstg_scan_upload_folders($upload_path);
        foreach ($folders as $folder) {
            // Create index.php, if it doesn't exist
            if (!file_exists($folder . 'index.php') && wp_is_writable($folder)) {
                @file_put_contents($folder . 'index.php', '<?php' . PHP_EOL . '// Silence is golden.');
            }
        }
        // Check for the files once per day
        set_transient('wpstg_check_protection_files', true, 3600 * 24);
    }
}