| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPAdminify\Inc\Modules\AdminPages; |
| 4 |
|
| 5 |
use WPAdminify\Inc\Classes\Icons_Library; |
| 6 |
use WPAdminify\Inc\Modules\AdminPages\AdminPages_PostType; |
| 7 |
use WPAdminify\Inc\Modules\AdminPages\AdminPages_MetaBoxes; |
| 8 |
use WPAdminify\Inc\Modules\AdminPages\AdminPages_Output; |
| 9 |
|
| 10 |
// no direct access allowed |
| 11 |
if (!defined('ABSPATH')) exit; |
| 12 |
|
| 13 |
/** |
| 14 |
* WPAdminify |
| 15 |
* @package Admin Pages |
| 16 |
* |
| 17 |
* @author Jewel Theme <support@jeweltheme.com> |
| 18 |
*/ |
| 19 |
|
| 20 |
class AdminPages extends AdminPages_MetaBoxes |
| 21 |
{ |
| 22 |
protected $module_url; |
| 23 |
|
| 24 |
public function __construct() |
| 25 |
{ |
| 26 |
$this->module_url = WP_ADMINIFY_URL . 'Inc/Modules/AdminPages'; |
| 27 |
$this->options = (new AdminPages_MetaBoxes())->get(); |
| 28 |
|
| 29 |
if (is_admin()) { |
| 30 |
add_action('admin_menu', [$this, 'admin_pages_submenu'], 53); |
| 31 |
add_action('network_admin_menu', [$this, 'admin_pages_submenu'], 53); |
| 32 |
new Icons_Library(); |
| 33 |
new AdminPages_PostType(); |
| 34 |
new AdminPages_Output(); |
| 35 |
|
| 36 |
|
| 37 |
// TO DO: Major Page builder supports. |
| 38 |
// add_action('elementor/init', [$this, 'elementor_support']); |
| 39 |
// add_action( 'init', [$this, 'jltwp_adminify_beaver_support' ] ); |
| 40 |
// add_action( 'init', [$this, 'jltwp_adminify_brizy_support' ] ); |
| 41 |
// add_action( 'init', [$this, 'jltwp_adminify_divi_support' ] ); |
| 42 |
|
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Submenu: Admin Pages |
| 48 |
* |
| 49 |
* @return void |
| 50 |
*/ |
| 51 |
public function admin_pages_submenu() |
| 52 |
{ |
| 53 |
add_submenu_page( |
| 54 |
'wp-adminify-settings', |
| 55 |
esc_html__('Admin Pages by WP Adminify', WP_ADMINIFY_TD), |
| 56 |
esc_html__('Admin Pages', WP_ADMINIFY_TD), |
| 57 |
apply_filters('jltwp_adminify_capability', 'manage_options'), |
| 58 |
'edit.php?post_type=adminify_admin_page' |
| 59 |
); |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Automatically Add Elementor Support |
| 64 |
* for adminify_admin_page CTP |
| 65 |
* |
| 66 |
* @return void |
| 67 |
*/ |
| 68 |
public function elementor_support() |
| 69 |
{ |
| 70 |
|
| 71 |
$post_types = $this->options['elementor_cpt_support']; |
| 72 |
|
| 73 |
if (!in_array('adminify_admin_page', $post_types, true)) { |
| 74 |
array_push($post_types, 'adminify_admin_page'); |
| 75 |
update_option('elementor_cpt_support', $post_types, true); |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
/** |
| 80 |
* Automatically Add Beaver Builder Support |
| 81 |
* for adminify_admin_page CTP |
| 82 |
* |
| 83 |
* @return void |
| 84 |
*/ |
| 85 |
public function jltwp_adminify_beaver_support() |
| 86 |
{ |
| 87 |
if (!class_exists('FLBuilderModel')) { |
| 88 |
return; |
| 89 |
} |
| 90 |
|
| 91 |
$post_types = \FLBuilderModel::get_post_types(); |
| 92 |
|
| 93 |
if (!in_array('adminify_admin_page', $post_types, true)) { |
| 94 |
array_push($post_types, 'adminify_admin_page'); |
| 95 |
\FLBuilderModel::update_admin_settings_option('_fl_builder_post_types', $post_types, true); |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
/** |
| 101 |
* Automatically Add Brizy Builder Support |
| 102 |
* for adminify_admin_page CTP |
| 103 |
* |
| 104 |
* @return void |
| 105 |
*/ |
| 106 |
public function jltwp_adminify_brizy_support() |
| 107 |
{ |
| 108 |
|
| 109 |
if (!class_exists('Brizy_Editor_Storage_Common')) { |
| 110 |
return; |
| 111 |
} |
| 112 |
|
| 113 |
$post_types = \Brizy_Editor_Storage_Common::instance()->get('post-types'); |
| 114 |
|
| 115 |
if (!in_array('adminify_admin_page', $post_types, true)) { |
| 116 |
array_push($post_types, 'adminify_admin_page'); |
| 117 |
\Brizy_Editor_Storage_Common::instance()->set('post-types', $post_types); |
| 118 |
} |
| 119 |
} |
| 120 |
|
| 121 |
|
| 122 |
/** |
| 123 |
* Automatically Add Divi Builder Support |
| 124 |
* for adminify_admin_page CTP |
| 125 |
* |
| 126 |
* @return void |
| 127 |
*/ |
| 128 |
public function jltwp_adminify_divi_support() |
| 129 |
{ |
| 130 |
// Divi uses 2 option meta. |
| 131 |
$divi_integrations = array( |
| 132 |
'et_divi_builder_plugin' => 'et_pb_post_type_integration', |
| 133 |
'et_pb_builder_options' => 'post_type_integration_main_et_pb_post_type_integration', |
| 134 |
); |
| 135 |
|
| 136 |
foreach ($divi_integrations as $option_name => $integration_key) { |
| 137 |
$options = get_option($option_name, array()); |
| 138 |
$post_types = isset($options[$integration_key]) ? $options[$integration_key] : array(); |
| 139 |
|
| 140 |
if (!isset($post_types['adminify_admin_page']) || 'on' !== $post_types['adminify_admin_page']) { |
| 141 |
$options[$integration_key]['adminify_admin_page'] = 'on'; |
| 142 |
|
| 143 |
update_option($option_name, $options, true); |
| 144 |
} |
| 145 |
} |
| 146 |
} |
| 147 |
} |
| 148 |
|