Example #1
0
 /**
  * Helper Functions
  */
 function helper_functions()
 {
     // grab user defined functions
     $functions = get_defined_functions();
     unset($functions['internal']);
     $tina_functions = array();
     $functions_file = file_get_contents(\TINA_MVC\tina_mvc_folder() . '/helpers/tina_mvc_functions.php');
     foreach ($functions['user'] as $f) {
         if (strpos($f, 'tina_mvc\\') === 0 and strpos($f, 'tina_mvc\\utils') === FALSE) {
             $function_offset = strpos($functions_file, 'function ' . str_replace('tina_mvc\\', '', $f));
             $functions_file_part = substr($functions_file, 0, $function_offset);
             $start_char = strrpos($functions_file_part, '/**');
             $end_char = strrpos($functions_file_part, '*/');
             $docBlockComment = substr($functions_file, $start_char, $end_char - $start_char + 2);
             $start_char = strpos($functions_file, '(', $function_offset);
             $end_char = strpos($functions_file, ')', $function_offset);
             $function_params = substr($functions_file, $start_char, $end_char - $start_char + 1);
             $tina_functions[$f]['function'] = $f . $function_params;
             $tina_functions[$f]['docblock'] = $docBlockComment;
         }
     }
     $this->add_var_e('tina_functions', $tina_functions);
     $this->set_post_content($this->load_view('admin_pages_helper_functions', $this->view_data, 'tina_mvc/admin_pages'));
 }
Example #2
0
 /**
  * Calls the todo_list controller for Tina MVC documentation
  */
 function admin_page_todo_list()
 {
     echo \Tina_MVC::call_controller('admin-pages/todo-list', FALSE, 'manage_options', \TINA_MVC\tina_mvc_folder() . '/admin_pages');
 }
Example #3
0
 /**
  * Sets up the WP hooks
  */
 public function __construct()
 {
     /**
      * For dev only...
      */
     // ini_set('error_reporting',E_ALL);
     add_shortcode('tina_mvc', array($this, 'shortcode'));
     add_filter('parse_query', array($this, 'wp_query_checker'));
     add_filter('the_posts', array($this, 'posts_filter'));
     add_action('widgets_init', array($this, 'setup_widget'));
     add_filter('the_content', array($this, 'setup_shortcode'), 7);
     if (TINA_MVC\get_tina_mvc_setting('init_bootstrap')) {
         add_action('init', array($this, 'do_init_bootstrap_funcs'));
     }
     /**
      * Following are only required for Administration panel
      */
     if (is_admin()) {
         include_once TINA_MVC\tina_mvc_folder() . '/admin_pages/admin_functions.php';
         new TINA_MVC\utils\admin_options_page();
         register_activation_hook(__FILE__, array($this, 'plugin_install'));
         register_deactivation_hook(__FILE__, array($this, 'plugin_remove'));
         add_filter('upgrader_pre_install', array($this, 'hpt_backup'), 10, 2);
         add_filter('upgrader_post_install', array($this, 'hpt_recover'), 10, 2);
     }
     /**
      * Following are only valid if Tina MVC is active
      */
     if (get_option('tina_mvc_plugin_active')) {
         // are we using custom login?
         if (TINA_MVC\get_tina_mvc_setting('custom_login')) {
             add_action('login_init', array($this, 'tina_mvc_login'));
             add_action('wp_logout', array($this, 'redirect_logout'));
         }
         if (TINA_MVC\get_tina_mvc_setting('roles_ok_for_wp_admin')) {
             add_action('admin_init', array($this, 'restrict_wp_admin'));
         }
         // custom cron?
         if (TINA_MVC\get_tina_mvc_setting('enable_hourly_cron')) {
             add_action('tina_mvc_cron_hook', array($this, 'hourly_cron'));
         }
         // wp_admin bar?
         $admin_bar_setting = TINA_MVC\get_tina_mvc_setting('wp_admin_bar');
         if ($admin_bar_setting === FALSE or $admin_bar_setting and !TINA_MVC\user_has_role($admin_bar_setting)) {
             show_admin_bar(FALSE);
         }
     }
     $this->default_role_to_view = TINA_MVC\get_tina_mvc_setting('default_role_to_view');
     $this->default_cap_to_view = TINA_MVC\get_tina_mvc_setting('default_capability_to_view');
 }