| 1 |
<?php |
| 2 |
/** |
| 3 |
* Class LP_Submenu_Tools |
| 4 |
*/ |
| 5 |
class LP_Submenu_Tools extends LP_Abstract_Submenu { |
| 6 |
|
| 7 |
/** |
| 8 |
* LP_Submenu_Tools constructor. |
| 9 |
*/ |
| 10 |
public function __construct() { |
| 11 |
$this->id = 'learn-press-tools'; |
| 12 |
$this->menu_title = __( 'Tools', 'learnpress' ); |
| 13 |
$this->page_title = __( 'LearnPress Tools', 'learnpress' ); |
| 14 |
$this->priority = 40; |
| 15 |
|
| 16 |
$this->tabs = apply_filters( |
| 17 |
'learn-press/admin/tools-tabs', |
| 18 |
array( |
| 19 |
'course' => __( 'Course Data', 'learnpress' ), |
| 20 |
'database' => __( 'Database', 'learnpress' ), |
| 21 |
'template' => __( 'Templates', 'learnpress' ), |
| 22 |
//'cron' => __( 'Cron Jobs', 'learnpress' ), |
| 23 |
//'cache' => __( 'Caches', 'learnpress' ), |
| 24 |
) |
| 25 |
); |
| 26 |
|
| 27 |
parent::__construct(); |
| 28 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) ); |
| 29 |
$this->_process_actions(); |
| 30 |
} |
| 31 |
|
| 32 |
public function admin_scripts() { |
| 33 |
learn_press_admin_assets()->enqueue_script( 'lp-update' ); |
| 34 |
} |
| 35 |
|
| 36 |
protected function _process_actions() { |
| 37 |
$has_action = true; |
| 38 |
switch ( LP_Request::get( 'page' ) ) { |
| 39 |
default: |
| 40 |
$has_action = false; |
| 41 |
} |
| 42 |
|
| 43 |
$nonce = LP_Request::get( '_wpnonce' ); |
| 44 |
|
| 45 |
if ( LP_Request::get( 'generate-cron-url' ) && $nonce ) { |
| 46 |
if ( wp_verify_nonce( $nonce ) ) { |
| 47 |
delete_option( 'learnpress_cron_url_nonce' ); |
| 48 |
|
| 49 |
wp_redirect( esc_url_raw( remove_query_arg( array( 'generate-cron-url', '_wpnonce' ) ) ) ); |
| 50 |
die(); |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
if ( $has_action ) { |
| 55 |
die(); |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
public function page_content_database() { |
| 60 |
learn_press_admin_view( 'tools/html-database' ); |
| 61 |
} |
| 62 |
|
| 63 |
public function page_content_template() { |
| 64 |
learn_press_admin_view( 'tools/html-template' ); |
| 65 |
} |
| 66 |
|
| 67 |
/*public function page_content_cache() { |
| 68 |
learn_press_admin_view( 'tools/html-cache' ); |
| 69 |
}*/ |
| 70 |
|
| 71 |
public function page_content_course() { |
| 72 |
learn_press_admin_view( 'tools/html-course' ); |
| 73 |
} |
| 74 |
|
| 75 |
/*public function page_content_cron() { |
| 76 |
learn_press_admin_view( 'tools/html-cron' ); |
| 77 |
}*/ |
| 78 |
|
| 79 |
/** |
| 80 |
* Display page |
| 81 |
*/ |
| 82 |
public function page_content() { |
| 83 |
parent::page_content(); |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
return new LP_Submenu_Tools(); |
| 88 |
|