예제 #1
0
function wp_stream_reports_intervals_html()
{
    $date = WP_Stream_Reports_Date_Interval::get_instance();
    // Default interval
    $default = array('key' => 'all-time', 'start' => '', 'end' => '');
    $user_interval = WP_Stream_Reports_Settings::get_user_options('interval', $default);
    $save_interval_url = add_query_arg(array_merge(array('action' => 'wp_stream_reports_save_interval'), WP_Stream_Reports::$nonce), admin_url('admin-ajax.php'));
    include WP_STREAM_REPORTS_VIEW_DIR . 'intervals.php';
}
예제 #2
0
 protected function get_section($id)
 {
     if (empty(self::$sections)) {
         self::$sections = WP_Stream_Reports_Settings::get_user_options('sections');
     }
     $section = self::$sections[$id];
     $section = $this->parse_section($section);
     $section['key'] = $id;
     return $section;
 }
예제 #3
0
 /**
  * Admin page callback function, redirects to each respective method based
  * on $_GET['view']
  *
  * @return void
  */
 public function page()
 {
     // Page class
     $class = 'metabox-holder columns-' . get_current_screen()->get_columns();
     $add_url = add_query_arg(array_merge(array('action' => 'wp_stream_reports_add_metabox'), self::$nonce), admin_url('admin-ajax.php'));
     $sections = WP_Stream_Reports_Settings::get_user_options('sections');
     $no_reports = empty($sections);
     $create_url = add_query_arg(array_merge(array('action' => 'wp_stream_reports_default_reports'), self::$nonce), admin_url('admin-ajax.php'));
     $no_reports_message = __("There's nothing here! Do you want to <a href=\"%s\">create some reports</a>?", 'stream-reports');
     $no_reports_message = sprintf($no_reports_message, $create_url);
     $view = (object) array('slug' => 'all', 'path' => null);
     // Avoid throwing Notices by testing the variable
     if (isset($_GET['view']) && !empty($_GET['view'])) {
         $view->slug = sanitize_file_name(wp_unslash($_GET['view']));
     }
     // First we check if the file exists in our plugin folder, otherwhise give the user an error
     if (!file_exists(WP_STREAM_REPORTS_VIEW_DIR . $view->slug . '.php')) {
         $view->slug = 'error';
     }
     // Define the path for the view we
     $view->path = WP_STREAM_REPORTS_VIEW_DIR . $view->slug . '.php';
     // Execute some actions before including the view, to allow others to hook in here
     // Use these to do stuff related to the view you are working with
     do_action('stream-reports-view', $view);
     do_action("stream-reports-view-{$view->slug}", $view);
     include_once $view->path;
 }