Пример #1
0
 /**
  * Initialize stats.
  *
  * @return void
  */
 public static function init()
 {
     self::$args = self::get_args();
     self::$stats_data = array();
     scb_register_table('app_stats_daily', self::$args['table_daily']);
     scb_register_table('app_stats_total', self::$args['table_total']);
     add_action('appthemes_first_run', array(__CLASS__, 'install'), 9);
     add_action('delete_post', array(__CLASS__, 'delete_post_stats'));
     add_action('wp_ajax_reset-stats', array(__CLASS__, 'ajax_reset_post_stats'));
     // Cron
     $cronjob = new scbCron('', array('callback' => array(__CLASS__, 'clear_daily_stats'), 'schedule' => 'daily'));
     add_action('appthemes_first_run', array($cronjob, 'reset'));
 }
Пример #2
0
/**
 * Load framework features.
 */
function _appthemes_load_features()
{
    // Checks if Features API used to load framework (temporary solution).
    // TODO: remove this checking and direct file loadings when all themes will use Features API.
    $is_feature_api = function_exists('appthemes_register_feature');
    if (current_theme_supports('app-wrapping') && !$is_feature_api) {
        require_once dirname(__FILE__) . '/includes/wrapping.php';
    }
    if (current_theme_supports('app-geo') && !$is_feature_api) {
        require_once dirname(__FILE__) . '/includes/geo.php';
    }
    if (current_theme_supports('app-login')) {
        if (!$is_feature_api) {
            require_once dirname(__FILE__) . '/includes/views-login.php';
        }
        list($templates) = get_theme_support('app-login');
        new APP_Login($templates['login']);
        new APP_Registration($templates['register']);
        new APP_Password_Recovery($templates['recover']);
        new APP_Password_Reset($templates['reset']);
    }
    if (current_theme_supports('app-feed')) {
        add_filter('request', 'appthemes_modify_feed_content');
    }
    if (current_theme_supports('app-stats')) {
        if (!$is_feature_api) {
            require_once dirname(__FILE__) . '/includes/stats.php';
        }
        APP_Post_Statistics::init();
    }
    if (current_theme_supports('app-open-graph')) {
        if (!$is_feature_api) {
            require_once dirname(__FILE__) . '/includes/open-graph.php';
        }
        list($args) = get_theme_support('app-open-graph');
        new APP_Open_Graph((array) $args);
    }
    if (is_admin() && current_theme_supports('app-versions') && !$is_feature_api) {
        require_once dirname(__FILE__) . '/admin/versions.php';
    }
    if (current_theme_supports('app-search-index')) {
        if (!$is_feature_api) {
            require_once dirname(__FILE__) . '/includes/search-index.php';
        }
        if (is_admin() && appthemes_search_index_get_args('admin_page')) {
            new APP_Search_Index_Admin();
        }
    }
    if (current_theme_supports('app-comment-counts') && !$is_feature_api) {
        require_once dirname(__FILE__) . '/includes/comment-counts.php';
    }
    if (current_theme_supports('app-term-counts') && !$is_feature_api) {
        require_once dirname(__FILE__) . '/includes/term-counts.php';
    }
    if (is_admin() && current_theme_supports('app-html-term-description')) {
        if (!$is_feature_api) {
            require_once dirname(__FILE__) . '/admin/class-html-term-description.php';
        }
        $args_sets = get_theme_support('app-html-term-description');
        if (!is_array($args_sets)) {
            $args_sets = array();
        }
        foreach ($args_sets as $args) {
            $args = wp_parse_args((array) $args, array('taxonomy' => '', 'editor_settings' => array()));
            new APP_HTML_Term_Description($args['taxonomy'], $args['editor_settings']);
        }
    }
    if (current_theme_supports('app-ajax-favorites')) {
        if (!$is_feature_api) {
            require_once dirname(__FILE__) . '/includes/ajax/class-ajax-view-favorites.php';
        }
        new APP_Ajax_View_Favorites();
    }
    if (current_theme_supports('app-ajax-delete')) {
        if (!$is_feature_api) {
            require_once dirname(__FILE__) . '/includes/ajax/class-ajax-view-delete-post.php';
        }
        new APP_Ajax_View_Delete_Post();
    }
    if (current_theme_supports('app-plupload') && !$is_feature_api) {
        require_once dirname(__FILE__) . '/app-plupload/app-plupload.php';
    }
    if (current_theme_supports('app-slider') && !$is_feature_api) {
        require_once dirname(__FILE__) . '/includes/slider/slider.php';
    }
    if (current_theme_supports('app-media-manager')) {
        if (!$is_feature_api) {
            require_once dirname(__FILE__) . '/media-manager/media-manager.php';
        }
        // Init media manager.
        new APP_Media_Manager();
    }
    if (is_admin() && current_theme_supports('app-dashboard')) {
        // Init dashboard.
        new APP_Dashboard(array('admin_action_priority' => 8));
        new APP_Settings();
        new APP_System_Info(array('admin_action_priority' => 99));
    }
    if (is_admin() && !class_exists('APP_Upgrader') && current_theme_supports('app-require-updater')) {
        add_action('admin_notices', '_appthemes_no_updater_plugin_warning');
    }
    // Init notices.
    APP_Notices::init();
    do_action('appthemes_framework_loaded');
}