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