/** * wp_ajax_wpsd_load_postviews function. * * @access public * @return void */ function wp_ajax_wpsd_load_postviews() { $form = new WPSDAdminConfigForm(); if ($form->getWpsdWidgetPostViews()) { $result = wpsd_read_cache(); echo '<!-- WP-Stats-Dashboard - START Post views -->'; // Parse posts views. $pattern = '<div id="postviews".*?>(.*?)<\\/div>'; preg_match_all('/' . $pattern . '/s', $result, $matches); $pv = preg_replace('/<h4>(.*?)<\\/h4>/s', '<h5>$1</h5>', $matches[1][0]); $pv = preg_replace('/<h3>(.*?)<\\/h3>/s', '<h4>Post views</h4>', $pv); $pv = str_replace('<table', '<table style="width:100%;"', $pv); if (defined('WPSD_PLUGIN_URL')) { $pv = str_replace('http://dashboard.wordpress.com/i/stats-icon.gif', WPSD_PLUGIN_URL . '/resources/images/stats-icon.gif', $pv); } $pv = str_replace('index.php?page=estats', 'index.php?page=stats', $pv); echo '<div style="overflow:hidden;">'; echo $pv; echo '</div>'; echo '<!-- WP-Stats-Dashboard - STOP Post views-->'; } else { _e('Widget disabled check', 'wpsd'); echo ' <a href="' . wpsd_get_settings_url() . '" title="wp-stats-dashboard settings" target="_self">' . __('settings', 'wpsd') . '</a>'; } exit; }