| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPAdminify\Inc\Admin\Options; |
| 4 |
|
| 5 |
use WPAdminify\Inc\Utils; |
| 6 |
use WPAdminify\Inc\Admin\AdminSettingsModel; |
| 7 |
|
| 8 |
if (!defined('ABSPATH')) { |
| 9 |
die; |
| 10 |
} // Cannot access directly. |
| 11 |
|
| 12 |
if (!class_exists('Module_Duplicate_Post')) { |
| 13 |
class Module_Duplicate_Post extends AdminSettingsModel |
| 14 |
{ |
| 15 |
public function __construct() |
| 16 |
{ |
| 17 |
$this->adminify_duplicate_post_settings(); |
| 18 |
} |
| 19 |
|
| 20 |
|
| 21 |
public function get_defaults() |
| 22 |
{ |
| 23 |
return [ |
| 24 |
'adminify_clone_post_user_roles' => [], |
| 25 |
'adminify_clone_post_posts' => ['page'], |
| 26 |
'adminify_clone_post_taxonomies' => [], |
| 27 |
]; |
| 28 |
} |
| 29 |
|
| 30 |
public function adminify_duplicate_post_user_roles(&$fields) |
| 31 |
{ |
| 32 |
|
| 33 |
$fields[] = array( |
| 34 |
'type' => 'subheading', |
| 35 |
'content' => Utils::adminfiy_help_urls( |
| 36 |
__('Duplicate Post/Page/Custom Post Types Settings', WP_ADMINIFY_TD), |
| 37 |
'https://wpadminify.com/kb/duplicate-post-using-wp-adminify/', |
| 38 |
'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8', |
| 39 |
'https://www.facebook.com/groups/jeweltheme', |
| 40 |
'https://wpadminify.com/support/post-page-custom-post-type-duplicator/' |
| 41 |
) |
| 42 |
); |
| 43 |
|
| 44 |
$fields[] = array( |
| 45 |
'id' => 'adminify_clone_post_user_roles', |
| 46 |
'type' => 'select', |
| 47 |
'title' => __('Disable for', WP_ADMINIFY_TD), |
| 48 |
'placeholder' => __('Select User roles you want to show', WP_ADMINIFY_TD), |
| 49 |
'options' => 'roles', |
| 50 |
'multiple' => true, |
| 51 |
'chosen' => true, |
| 52 |
'default' => $this->get_default_field('adminify_clone_post_user_roles'), |
| 53 |
); |
| 54 |
|
| 55 |
$fields[] = array( |
| 56 |
'id' => 'adminify_clone_post_posts', |
| 57 |
'type' => 'checkbox', |
| 58 |
'title' => __('Enable for Post Types', WP_ADMINIFY_TD), |
| 59 |
'subtitle' => __('Select Post Types for Enabling Duplicate feature', WP_ADMINIFY_TD), |
| 60 |
'options' => 'post_types', |
| 61 |
'query_args' => array( |
| 62 |
'orderby' => 'post_title', |
| 63 |
'order' => 'ASC', |
| 64 |
), |
| 65 |
'default' => $this->get_default_field('adminify_clone_post_posts'), |
| 66 |
); |
| 67 |
|
| 68 |
if (!jltwp_adminify()->can_use_premium_code__premium_only()) { |
| 69 |
$fields[] = array( |
| 70 |
'type' => 'notice', |
| 71 |
'style' => 'warning', |
| 72 |
'content' => Utils::adminify_upgrade_pro(), |
| 73 |
'dependency' => array( |
| 74 |
array('adminify_clone_post_posts', 'not-any', 'post,page', 'true'), |
| 75 |
array('adminify_clone_post_posts', '!=', '', 'true'), |
| 76 |
), |
| 77 |
); |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
public function adminify_duplicate_post_taxonomy(&$fields) |
| 83 |
{ |
| 84 |
if (jltwp_adminify()->can_use_premium_code__premium_only()) { |
| 85 |
$fields[] = array( |
| 86 |
'id' => 'adminify_clone_post_taxonomies', |
| 87 |
'type' => 'checkbox', |
| 88 |
'title' => __('Enable for Taxonomies', WP_ADMINIFY_TD), |
| 89 |
'options' => 'WPAdminify\Inc\Admin\Options\Module_PostTypesOrder::get_all_taxonomies', |
| 90 |
'query_args' => array( |
| 91 |
'orderby' => 'post_title', |
| 92 |
'order' => 'ASC', |
| 93 |
), |
| 94 |
'default' => $this->get_default_field('adminify_clone_post_taxonomies'), |
| 95 |
); |
| 96 |
} else { |
| 97 |
$fields[] = array( |
| 98 |
'type' => 'notice', |
| 99 |
'style' => 'warning', |
| 100 |
'title' => __('Enable for Taxonomies', WP_ADMINIFY_TD), |
| 101 |
'content' => Utils::adminify_upgrade_pro(), |
| 102 |
); |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
/** |
| 108 |
* Adminify Duplicate Post Settings |
| 109 |
*/ |
| 110 |
public function adminify_duplicate_post_settings() |
| 111 |
{ |
| 112 |
|
| 113 |
if (!class_exists('ADMINIFY')) { |
| 114 |
return; |
| 115 |
} |
| 116 |
|
| 117 |
$fields = []; |
| 118 |
$this->adminify_duplicate_post_user_roles($fields); |
| 119 |
// $this->adminify_duplicate_post_taxonomy($fields); |
| 120 |
|
| 121 |
// Duplicate Post Setttings |
| 122 |
\ADMINIFY::createSection($this->prefix, array( |
| 123 |
'title' => __('Duplicate Post', WP_ADMINIFY_TD), |
| 124 |
'id' => 'duplicate_post_section', |
| 125 |
'parent' => 'module_settings', |
| 126 |
'icon' => 'far fa-copy', |
| 127 |
'fields' => $fields |
| 128 |
)); |
| 129 |
} |
| 130 |
} |
| 131 |
} |
| 132 |
|