• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_statistics_validate_capability函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_statistics_validate_capability函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_statistics_validate_capability函数的具体用法?PHP wp_statistics_validate_capability怎么用?PHP wp_statistics_validate_capability使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_statistics_validate_capability函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: wp_statistics_download_manual

function wp_statistics_download_manual()
{
    global $WP_Statistics, $wpdb;
    // this is how you get access to the database
    $manage_cap = wp_statistics_validate_capability($WP_Statistics->get_option('manage_capability', 'manage_options'));
    if (current_user_can($manage_cap)) {
        $type = $_GET['type'];
        if ($type == 'odt' || $type == 'html') {
            $filepath = $WP_Statistics->plugin_dir . '/manual';
            $filename = '';
            $ext = '.' . $type;
            // open this directory
            $dir = opendir($filepath);
            // get each entry
            while ($entry = readdir($dir)) {
                if (substr($entry, -strlen($ext)) == $ext) {
                    $filename = $entry;
                }
            }
            // close directory
            closedir($dir);
            if ($filename != '') {
                $filename = substr($filename, 0, -strlen($ext));
                $filename .= ' V' . WP_STATISTICS_VERSION . $ext;
                header('Content-Type: application/octet-stream;');
                header('Content-Disposition: attachment; filename="' . $filename . '"');
                readfile($filepath . $filename);
            }
        }
    }
}
开发者ID:yszar,项目名称:linuxwp,代码行数:31,代码来源:manual.php


示例2: wp_statistics_dashboard_widget_load

function wp_statistics_dashboard_widget_load()
{
    global $WP_Statistics;
    $WP_Statistics->load_user_options();
    // We need to fudge the display settings for first time users so not all of the widgets are displayed, we only want to do this on
    // the first time they visit the dashboard though so check to see if we've been here before.
    if (!$WP_Statistics->get_user_option('dashboard_set')) {
        $WP_Statistics->update_user_option('dashboard_set', WP_STATISTICS_VERSION);
        $hidden_widgets = get_user_meta($WP_Statistics->user_id, 'metaboxhidden_dashboard', true);
        if (!is_array($hidden_widgets)) {
            $hidden_widgets = array();
        }
        $default_hidden = array('wp-statistics-browsers-widget', 'wp-statistics-countries-widget', 'wp-statistics-hitsmap-widget', 'wp-statistics-hits-widget', 'wp-statistics-pages-widget', 'wp-statistics-recent-widget', 'wp-statistics-referring-widget', 'wp-statistics-search-widget', 'wp-statistics-summary-widget', 'wp-statistics-words-widget', 'wp-statistics-top-visitors-widget');
        foreach ($default_hidden as $widget) {
            if (!in_array($widget, $hidden_widgets)) {
                $hidden_widgets[] = $widget;
            }
        }
        update_user_meta($WP_Statistics->user_id, 'metaboxhidden_dashboard', $hidden_widgets);
    } else {
        if ($WP_Statistics->get_user_option('dashboard_set') != WP_STATISTICS_VERSION) {
            // We also have to fudge things when we add new widgets to the code base.
            if (version_compare($WP_Statistics->get_user_option('dashboard_set'), '8.7', '<')) {
                $WP_Statistics->update_user_option('dashboard_set', WP_STATISTICS_VERSION);
                $hidden_widgets = get_user_meta($WP_Statistics->user_id, 'metaboxhidden_dashboard', true);
                if (!is_array($hidden_widgets)) {
                    $hidden_widgets = array();
                }
                $default_hidden = array('wp-statistics-top-visitors-widget');
                foreach ($default_hidden as $widget) {
                    if (!in_array($widget, $hidden_widgets)) {
                        $hidden_widgets[] = $widget;
                    }
                }
                update_user_meta($WP_Statistics->user_id, 'metaboxhidden_dashboard', $hidden_widgets);
            }
        }
    }
    // If the user does not have at least read access to the status plugin, just return without adding the widgets.
    if (!current_user_can(wp_statistics_validate_capability($WP_Statistics->get_option('read_capability', 'manage_option')))) {
        return;
    }
    // If the admin has disabled the widgets, don't display them.
    if (!$WP_Statistics->get_option('disable_dashboard')) {
        wp_add_dashboard_widget('wp-statistics-quickstats-widget', __('Quick Stats', 'wp_statistics'), 'wp_statistics_quickstats_widget', $control_callback = null);
        wp_add_dashboard_widget('wp-statistics-browsers-widget', __('Top 10 Browsers', 'wp_statistics'), 'wp_statistics_browsers_widget', $control_callback = null);
        wp_add_dashboard_widget('wp-statistics-countries-widget', __('Top 10 Countries', 'wp_statistics'), 'wp_statistics_countries_widget', $control_callback = null);
        wp_add_dashboard_widget('wp-statistics-hitsmap-widget', __('Today\'s Visitor Map', 'wp_statistics'), 'wp_statistics_hitsmap_widget', $control_callback = null);
        wp_add_dashboard_widget('wp-statistics-hits-widget', __('Hit Statistics', 'wp_statistics'), 'wp_statistics_hits_widget', $control_callback = null);
        wp_add_dashboard_widget('wp-statistics-pages-widget', __('Top 10 Pages', 'wp_statistics'), 'wp_statistics_pages_widget', $control_callback = null);
        wp_add_dashboard_widget('wp-statistics-recent-widget', __('Recent Visitors', 'wp_statistics'), 'wp_statistics_recent_widget', $control_callback = null);
        wp_add_dashboard_widget('wp-statistics-referring-widget', __('Top Referring Sites', 'wp_statistics'), 'wp_statistics_referring_widget', $control_callback = null);
        wp_add_dashboard_widget('wp-statistics-search-widget', __('Search Engine Referrals', 'wp_statistics'), 'wp_statistics_search_widget', $control_callback = null);
        wp_add_dashboard_widget('wp-statistics-summary-widget', __('Summary', 'wp_statistics'), 'wp_statistics_summary_widget', $control_callback = null);
        wp_add_dashboard_widget('wp-statistics-words-widget', __('Latest Search Words', 'wp_statistics'), 'wp_statistics_words_widget', $control_callback = null);
        wp_add_dashboard_widget('wp-statistics-top-visitors-widget', __('Top 10 Visitors Today', 'wp_statistics'), 'wp_statistics_top_visitors_widget', $control_callback = null);
    }
}
开发者ID:dtekcth,项目名称:datateknologer.se,代码行数:58,代码来源:dashboard.php


示例3: wp_statistics_generate_about_postbox_content

function wp_statistics_generate_about_postbox_content()
{
    global $wpdb, $WP_Statistics;
    ?>

						<div style="text-align: center;">
							<a href="http://wp-statistics.com" target="_blank"><img src="<?php 
    echo plugins_url('wp-statistics/assets/images/logo-250.png');
    ?>
"></a>
						</div>

						<div id="about-links" style="text-align: center;">
							<p><a href="http://wp-statistics.com" target="_blank"><?php 
    _e('Website', 'wp_statistics');
    ?>
</a></p>
							| <p><a href="http://wordpress.org/support/view/plugin-reviews/wp-statistics" target="_blank"><?php 
    _e('Rate and Review', 'wp_statistics');
    ?>
</a></p>
<?php 
    if (current_user_can(wp_statistics_validate_capability($WP_Statistics->get_option('manage_capability', 'manage_options')))) {
        ?>

							| <p><a href="?page=wp-statistics/settings&tab=about"><?php 
        _e('More Information', 'wp_statistics');
        ?>
</a></p>
<?php 
    }
    ?>

						</div>

						<hr />
						
						<div>
							<?php 
    echo sprintf(__('This product includes GeoLite2 data created by MaxMind, available from %s.', 'wp_statistics'), '<a href="http://www.maxmind.com" target=_blank>http://www.maxmind.com</a>');
    ?>

						</div>
<?php 
}
开发者ID:vanlong200880,项目名称:uni,代码行数:45,代码来源:about.php


示例4: wp_statistics_add_editor_meta_box

function wp_statistics_add_editor_meta_box()
{
    global $WP_Statistics;
    $WP_Statistics->load_user_options();
    // We need to fudge the display settings for first time users so not all of the widgets are disaplyed, we only want to do this on
    // the first time they visit the dashboard though so check to see if we've been here before.
    if (!$WP_Statistics->get_user_option('editor_set')) {
        $WP_Statistics->update_user_option('editor_set', WP_STATISTICS_VERSION);
        $hidden_widgets = get_user_meta($WP_Statistics->user_id, 'metaboxhidden_post', true);
        if (!is_array($hidden_widgets)) {
            $hidden_widgets = array();
        }
        if (!in_array('wp_statistics_editor_meta_box', $hidden_widgets)) {
            $hidden_widgets[] = 'wp_statistics_editor_meta_box';
        }
        update_user_meta($WP_Statistics->user_id, 'metaboxhidden_post', $hidden_widgets);
        $hidden_widgets = get_user_meta($WP_Statistics->user_id, 'metaboxhidden_page', true);
        if (!is_array($hidden_widgets)) {
            $hidden_widgets = array();
        }
        if (!in_array('wp_statistics_editor_meta_box', $hidden_widgets)) {
            $hidden_widgets[] = 'wp_statistics_editor_meta_box';
        }
        update_user_meta($WP_Statistics->user_id, 'metaboxhidden_page', $hidden_widgets);
    }
    // If the user does not have at least read access to the status plugin, just return without adding the widgets.
    if (!current_user_can(wp_statistics_validate_capability($WP_Statistics->get_option('read_capability', 'manage_option')))) {
        return;
    }
    // If the admin has disabled the widgets don't display them.
    if ($WP_Statistics->get_option('disable_editor')) {
        return;
    }
    $screens = array('post', 'page');
    foreach ($screens as $screen) {
        add_meta_box('wp_statistics_editor_meta_box', __('Hit Statistics', 'wp_statistics'), 'wp_statistics_editor_meta_box', $screen, 'normal', 'high');
    }
}
开发者ID:bqevin,项目名称:wp-shopeasy,代码行数:38,代码来源:editor.php


示例5: wp_statistics_purge_visitor_hits_action_callback

function wp_statistics_purge_visitor_hits_action_callback()
{
    global $WP_Statistics, $wpdb;
    // this is how you get access to the database
    require $WP_Statistics->plugin_dir . '/includes/functions/purge-hits.php';
    $manage_cap = wp_statistics_validate_capability($WP_Statistics->get_option('manage_capability', 'manage_options'));
    if (current_user_can($manage_cap)) {
        $purge_hits = 10;
        if (array_key_exists('purge-hits', $_POST)) {
            // Get the number of days to purge data before.
            $purge_hits = intval($_POST['purge-hits']);
        }
        if ($purge_hits < 10) {
            _e('Number of hits must be greater than or equal to 10!', 'wp_statistics');
        } else {
            echo wp_statistics_purge_visitor_hits($purge_hits);
        }
    } else {
        _e('Access denied!', 'wp_statistics');
    }
    wp_die();
    // this is required to terminate immediately and return a proper response
}
开发者ID:vanlong200880,项目名称:uni,代码行数:23,代码来源:ajax.php


示例6: wp_statistics_settings

function wp_statistics_settings()
{
    global $WP_Statistics;
    // Check the current user has the rights to be here.
    if (!current_user_can(wp_statistics_validate_capability($WP_Statistics->get_option('read_capability', 'manage_options')))) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    // When we create $WP_Statistics the user has not been authenticated yet so we cannot load the user preferences
    // during the creation of the class.  Instead load them now that the user exists.
    $WP_Statistics->load_user_options();
    // Load our CSS to be used.
    wp_enqueue_style('log-css', plugin_dir_url(__FILE__) . 'assets/css/style.css', true, '1.0');
    // Load the jQuery UI code to create the tabs.
    wp_register_style("jquery-ui-css", plugin_dir_url(__FILE__) . "assets/css/jquery-ui-1.10.4.custom.css");
    wp_enqueue_style("jquery-ui-css");
    wp_enqueue_script('jquery-ui-core');
    wp_enqueue_script('jquery-ui-tabs');
    if (is_rtl()) {
        wp_enqueue_style('rtl-css', plugin_dir_url(__FILE__) . 'assets/css/rtl.css', true, '1.1');
    }
    // We could let the download happen at the end of the page, but this way we get to give some
    // feedback to the users about the result.
    if ($WP_Statistics->get_option('update_geoip') == true) {
        echo wp_statistics_download_geoip();
    }
    include_once dirname(__FILE__) . "/includes/settings/wps-settings.php";
}
开发者ID:lykeven,项目名称:graspzhihu,代码行数:27,代码来源:wp-statistics.php


示例7:

<?php

$wps_nonce_valid = false;
if (array_key_exists('wp-statistics-nonce', $_POST)) {
    if (wp_verify_nonce($_POST['wp-statistics-nonce'], 'update-options')) {
        $wps_nonce_valid = true;
    }
}
$wps_admin = false;
if (current_user_can(wp_statistics_validate_capability($WP_Statistics->get_option('manage_capability', 'manage_options')))) {
    $wps_admin = true;
}
if ($wps_admin === false) {
    $wps_admin = 0;
}
$selected_tab = "";
if (array_key_exists('tab', $_GET)) {
    $selected_tab = $_GET['tab'];
}
switch ($selected_tab) {
    case 'notifications':
        if ($wps_admin) {
            $current_tab = 1;
        } else {
            $current_tab = 0;
        }
        break;
    case 'overview':
        if ($wps_admin) {
            $current_tab = 2;
        } else {
开发者ID:bqevin,项目名称:wp-shopeasy,代码行数:31,代码来源:wps-settings.php


示例8: wp_statistics_get_widget_contents_callback

function wp_statistics_get_widget_contents_callback()
{
    global $WP_Statistics, $wpdb;
    // this is how you get access to the database
    $widgets = array('about', 'browsers', 'map', 'countries', 'hits', 'hitsmap', 'page', 'pages', 'quickstats', 'recent', 'referring', 'search', 'summary', 'top.visitors', 'words');
    $view_cap = wp_statistics_validate_capability($WP_Statistics->get_option('read_capability', 'manage_options'));
    if (current_user_can($view_cap)) {
        $widget = '';
        if (array_key_exists('widget', $_POST)) {
            // Get the widget we're going to display.
            if (in_array($_POST['widget'], $widgets)) {
                $widget = $_POST['widget'];
            }
        }
        if ('map' == $widget || 'hitsmap' == $widget) {
            if ($WP_Statistics->get_option('map_type') == 'jqvmap') {
                $widget = 'jqv.map';
            } else {
                $widget = 'google.map';
            }
        }
        if ('' == $widget) {
            _e('No matching widget found!', 'wp_statistics');
            wp_die();
        }
        $ISOCountryCode = $WP_Statistics->get_country_codes();
        $search_engines = wp_statistics_searchengine_list();
        require $WP_Statistics->plugin_dir . '/includes/log/widgets/' . $widget . '.php';
        switch ($widget) {
            case 'summary':
                wp_statistics_generate_summary_postbox_content($search_engines);
                break;
            case 'quickstats':
                wp_statistics_generate_quickstats_postbox_content($search_engines);
                break;
            case 'browsers':
                wp_statistics_generate_browsers_postbox_content();
                break;
            case 'referring':
                wp_statistics_generate_referring_postbox_content();
                break;
            case 'countries':
                wp_statistics_generate_countries_postbox_content($ISOCountryCode);
                break;
            case 'jqv.map':
            case 'google.map':
                wp_statistics_generate_map_postbox_content($ISOCountryCode);
                break;
            case 'hits':
                wp_statistics_generate_hits_postbox_content();
                break;
            case 'search':
                wp_statistics_generate_search_postbox_content($search_engines);
                break;
            case 'words':
                wp_statistics_generate_words_postbox_content($ISOCountryCode);
                break;
            case 'page':
                $pageid = (int) $_POST['page-id'];
                wp_statistics_generate_page_postbox_content(null, $pageid);
                break;
            case 'pages':
                list($total, $uris) = wp_statistics_get_top_pages();
                wp_statistics_generate_pages_postbox_content($total, $uris);
                break;
            case 'recent':
                wp_statistics_generate_recent_postbox_content($ISOCountryCode);
                break;
            case 'top.visitors':
                wp_statistics_generate_top_visitors_postbox_content($ISOCountryCode);
                break;
            case 'about':
                wp_statistics_generate_about_postbox_content($ISOCountryCode);
                break;
            default:
                _e('ERROR: Widget not found!', 'wp_statistics');
        }
    } else {
        _e('Access denied!', 'wp_statistics');
    }
    wp_die();
    // this is required to terminate immediately and return a proper response
}
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:83,代码来源:ajax.php


示例9: wp_statistics_export_data

function wp_statistics_export_data()
{
    global $WP_Statistics, $wpdb;
    // this is how you get access to the database
    $manage_cap = wp_statistics_validate_capability($WP_Statistics->get_option('manage_capability', 'manage_options'));
    if (current_user_can($manage_cap)) {
        $table = $_POST['table-to-export'];
        $type = $_POST['export-file-type'];
        $headers = $_POST['export-headers'];
        // Validate the table name the user passed to us.
        if (!($table == "useronline" || $table == "visit" || $table == "visitor" || $table == "exclusions" || $table == "pages")) {
            $table = FALSE;
        }
        // Validate the file type the user passed to us.
        if (!($type == "excel" || $type == "xml" || $type == "csv" || $type == "tsv")) {
            $table = FALSE;
        }
        if ($table && $type) {
            require $WP_Statistics->plugin_dir . '/includes/classes/php-export-data.class.php';
            $file_name = WPS_EXPORT_FILE_NAME . '-' . $WP_Statistics->Current_Date('Y-m-d-H-i');
            switch ($type) {
                case 'excel':
                    $exporter = new ExportDataExcel('browser', "{$file_name}.xls");
                    break;
                case 'xml':
                    $exporter = new ExportDataExcel('browser', "{$file_name}.xml");
                    break;
                case 'csv':
                    $exporter = new ExportDataCSV('browser', "{$file_name}.csv");
                    break;
                case 'tsv':
                    $exporter = new ExportDataTSV('browser', "{$file_name}.tsv");
                    break;
            }
            $exporter->initialize();
            // We need to limit the number of results we retrieve to ensure we don't run out of memory
            $query_base = "SELECT * FROM {$wpdb->prefix}statistics_{$table}";
            $query = $query_base . ' LIMIT 0,1000';
            $i = 1;
            $more_results = true;
            $result = $wpdb->get_results($query, ARRAY_A);
            if ($headers) {
                foreach ($result[0] as $key => $col) {
                    $columns[] = $key;
                }
                $exporter->addRow($columns);
            }
            while ($more_results) {
                foreach ($result as $row) {
                    $exporter->addRow($row);
                    // Make sure we've flushed the output buffer so we don't run out of memory on large exports.
                    ob_flush();
                    flush();
                }
                unset($result);
                $wpdb->flush();
                $query = $query_base . ' LIMIT ' . $i * 1000 . ',1000';
                $result = $wpdb->get_results($query, ARRAY_A);
                if (count($result) == 0) {
                    $more_results = false;
                }
                $i++;
            }
            $exporter->finalize();
            exit;
        }
    }
}
开发者ID:lykeven,项目名称:graspzhihu,代码行数:68,代码来源:export.php



注:本文中的wp_statistics_validate_capability函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_statistics_visit函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_statistics_useronline函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap