Exemplo n.º 1
0
/**
 * Pre-upgrade actions
 *
 * Copies any custom themes, uniform themes and languages files to a temporary directory
 */
function iphorm_pre_upgrade($value, $extra_args)
{
    if (isset($extra_args['plugin']) && $extra_args['plugin'] == IPHORM_PLUGIN_BASENAME) {
        global $wp_filesystem;
        $pluginPath = untrailingslashit($wp_filesystem->wp_plugins_dir());
        $iphormPluginPath = $pluginPath . '/' . IPHORM_PLUGIN_NAME;
        $allUniformThemes = iphorm_get_all_uniform_themes();
        $defaultUniformThemes = iphorm_get_default_uniform_themes();
        $uniformThemesToBackup = array();
        foreach ($allUniformThemes as $allUniformTheme) {
            if (!in_array($allUniformTheme['Folder'], $defaultUniformThemes)) {
                $uniformThemesToBackup[] = $allUniformTheme['Folder'];
            }
        }
        $allThemes = iphorm_get_all_themes();
        $defaultThemes = iphorm_get_default_themes();
        $themesToBackup = array();
        foreach ($allThemes as $allTheme) {
            if (!in_array($allTheme['Folder'], $defaultThemes)) {
                $themesToBackup[] = $allTheme['Folder'];
            }
        }
        $languageFilesToBackup = iphorm_get_custom_language_files();
        $customCSS = $wp_filesystem->is_file($iphormPluginPath . '/css/custom.css');
        if (count($uniformThemesToBackup) || count($themesToBackup) || count($languageFilesToBackup) || $customCSS) {
            if ($wp_filesystem->is_writable($pluginPath)) {
                $targetDir = $pluginPath . '/iphorm-upgrade.tmp';
                if ($wp_filesystem->exists($targetDir)) {
                    $wp_filesystem->delete($targetDir, true);
                }
                if (!$wp_filesystem->exists($targetDir)) {
                    $wp_filesystem->mkdir($targetDir);
                    // All set, start copying themes over
                    if (count($uniformThemesToBackup)) {
                        $targetUniformDir = $targetDir . '/uniform/';
                        $wp_filesystem->mkdir($targetUniformDir);
                        $sourceUniformDir = $iphormPluginPath . '/js/uniform/themes/';
                        foreach ($uniformThemesToBackup as $uniformThemeToBackup) {
                            if ($wp_filesystem->exists($sourceUniformDir . $uniformThemeToBackup)) {
                                $wp_filesystem->mkdir($targetUniformDir . $uniformThemeToBackup);
                                copy_dir($sourceUniformDir . $uniformThemeToBackup, $targetUniformDir . $uniformThemeToBackup);
                            }
                        }
                    }
                    if (count($themesToBackup)) {
                        $targetThemeDir = $targetDir . '/themes/';
                        $wp_filesystem->mkdir($targetThemeDir);
                        $sourceThemeDir = $iphormPluginPath . '/themes/';
                        foreach ($themesToBackup as $themeToBackup) {
                            if ($wp_filesystem->exists($sourceThemeDir . $themeToBackup)) {
                                $wp_filesystem->mkdir($targetThemeDir . $themeToBackup);
                                copy_dir($sourceThemeDir . $themeToBackup, $targetThemeDir . $themeToBackup);
                            }
                        }
                    }
                    if (count($languageFilesToBackup)) {
                        $targetLanguagesDir = $targetDir . '/languages/';
                        $sourceLanguagesDir = $iphormPluginPath . '/languages/';
                        $wp_filesystem->mkdir($targetLanguagesDir);
                        foreach ($languageFilesToBackup as $languageFileToBackup) {
                            if ($wp_filesystem->is_file($sourceLanguagesDir . $languageFileToBackup)) {
                                $wp_filesystem->copy($sourceLanguagesDir . $languageFileToBackup, $targetLanguagesDir . $languageFileToBackup);
                            }
                        }
                    }
                    if ($customCSS) {
                        $wp_filesystem->copy($iphormPluginPath . '/css/custom.css', $targetDir . '/custom.css');
                    }
                }
            }
        }
    }
    return $value;
}
Exemplo n.º 2
0
    ?>
"></script>
<?php 
}
if (!get_option('iphorm_disable_jqueryui_output')) {
    if (version_compare(get_bloginfo('version'), '3.3') >= 0) {
        ?>
    <?php 
        wp_print_scripts(array('jquery-ui-datepicker'));
    } else {
        ?>
<script type="text/javascript" src="<?php 
        echo iphorm_plugin_url() . '/js/jqueryui/jquery.ui.core.min.js';
        ?>
"></script>
<script type="text/javascript" src="<?php 
        echo iphorm_plugin_url() . '/js/jqueryui/jquery.ui.datepicker.min.js';
        ?>
"></script>
<?php 
    }
}
$allThemes = iphorm_get_all_themes();
foreach ($allThemes as $theme) {
    if (file_exists(IPHORM_PLUGIN_DIR . "/themes/" . $theme['Folder'] . "/" . $theme['Filename'] . ".js")) {
        echo '<script type="text/javascript" src="' . iphorm_plugin_url() . "/themes/" . $theme['Folder'] . "/" . $theme['Filename'] . '.js"></script>' . PHP_EOL;
    }
}
?>
</body>
</html>