コード例 #1
0
function af_ela_option_init($reset = false)
{
    global $af_ela_cache_root;
    if (!$reset) {
        $settings = get_option('af_ela_options');
    }
    if (!($is_initialized = get_option('af_ela_is_initialized')) || empty($settings) || strstr(trim(af_ela_info('currentversion')), trim($is_initialized)) === false || strstr(trim($settings['installed_version']), trim($is_initialized)) === false || $reset) {
        $cache = new af_ela_classCacheFile('');
        $cache->deleteFile();
        $initSettings = array('id' => 'af-ela', 'installed_version' => af_ela_info('currentversion'), 'charset' => get_bloginfo('charset'), 'newest_first' => '1', 'num_entries' => 0, 'num_entries_tagged' => 0, 'num_comments' => 0, 'fade' => 0, 'hide_pingbacks_and_trackbacks' => 0, 'use_default_style' => 1, 'paged_posts' => 0, 'selected_text' => '', 'selected_class' => 'selected', 'comment_text' => '(%)', 'number_text' => '(%)', 'number_text_tagged' => '(%)', 'closed_comment_text' => '', 'day_format' => '', 'error_class' => 'alert', 'truncate_title_length' => '0', 'truncate_cat_length' => '25', 'truncate_title_text' => '&#8230;', 'truncate_title_at_space' => 1, 'abbreviated_month' => 0, 'tag_soup_cut' => 0, 'tag_soup_X' => 0, 'paged_post_num' => 10, 'paged_post_next' => 'next posts >>', 'paged_post_prev' => '<< previous posts', 'menu_order' => 'chrono,cats', 'menu_month' => 'By date', 'menu_cat' => 'By category', 'menu_tag' => 'By tags', 'before_child' => '&nbsp;&nbsp;&nbsp;', 'after_child' => '', 'loading_content' => '...loading', 'idle_content' => '', 'excluded_categories' => '0');
        if (!empty($settings)) {
            $newSettings = array_merge($initSettings, $settings);
        } else {
            $newSettings = $initSettings;
        }
        $newSettings['last_modified'] = gmdate("D, d M Y H:i:s", time());
        $newSettings['installed_version'] = af_ela_info('currentversion');
        update_option('af_ela_options', $newSettings, 'Set of Options for Extended Live Archive');
        update_option('af_ela_option_mode', get_option('af_ela_options') ? 1 : 0, 'ELA option mode');
        $res = true;
        if (!is_dir($af_ela_cache_root)) {
            if (!($res = af_ela_create_cache_dir())) {
                ?>
		<div class="updated"><p><strong>Unable to create cache directory. Check your server credentials on the wp-content directory.</strong></p></div>
	<?php 
                return;
            } else {
                if ($res === true) {
                    $res = af_ela_create_cache($settings);
                    if ($res === true) {
                        ?>
		<div class="updated"><p><strong>The cache files have been created for the first time. You should be up and running. Enjoy.</strong></p></div>
	<?php 
                    } else {
                        ?>
		<div class="updated"><p><strong>Unable to create the cache files. Check your server credentials on the wp-content/af-extended-live-archive directory. </strong></p></div>
	<?php 
                        return;
                    }
                }
            }
        } else {
            if (af_ela_create_cache($settings)) {
                if (!$reset) {
                    ?>
		<div class="updated"><p><strong>The cache files have been updated. You should be up and running. Enjoy.</strong></p></div>
	<?php 
                }
            } else {
                ?>
		<div class="updated"><p><strong>Unable to update the cache files to the newer version of the plugin. Check your server credentials on the wp-content/af-extended-live-archive directory. </strong></p></div>
	<?php 
                return;
            }
        }
        update_option('af_ela_is_initialized', af_ela_info('currentversion'), 'ELA plugin has already been initialized');
    }
}
コード例 #2
0
function af_ela_create_cache($settings)
{
    global $wpdb, $af_ela_cache_root, $utw_is_present;
    if (!is_dir($af_ela_cache_root)) {
        if (!af_ela_create_cache_dir()) {
            return false;
        }
    }
    $generator = new af_ela_classGenerator();
    if (!$settings['tag_soup_cut'] || empty($settings['tag_soup_X'])) {
        $order = false;
    } else {
        $order = $settings['tag_soup_cut'];
        $orderparam = $settings['tag_soup_X'];
    }
    $generator->buildYearsTable($settings['excluded_categories']);
    $generator->buildMonthsTable($settings['excluded_categories']);
    $generator->buildPostsInMonthsTable($settings['excluded_categories'], $settings['hide_pingbacks_and_trackbacks']);
    $generator->buildCatsTable($settings['excluded_categories']);
    $generator->buildPostsInCatsTable($settings['excluded_categories'], $settings['hide_pingbacks_and_trackbacks']);
    if ($utw_is_present) {
        $ret = $generator->buildTagsTable($settings['excluded_categories'], false, $order, $orderparam);
    }
    if ($ret && $utw_is_present) {
        $generator->buildPostsInTagsTable($settings['excluded_categories'], $settings['hide_pingbacks_and_trackbacks']);
    }
    return true;
}