-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbackup.php
More file actions
114 lines (84 loc) · 3.64 KB
/
Copy pathbackup.php
File metadata and controls
114 lines (84 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// define the use of autoload
use Inc\Activate;
use Inc\Deactivate;
require_once plugin_dir_path(__FILE__) . 'inc/Admin/AdminPages.php';
// start check if class already exists
if (!class_exists('Cherki_Hamza_Plugin')) {
class Cherki_Hamza_Plugin
{
public $plugin;
function __construct(){
$this->plugin = plugin_basename(__FILE__);
/* $path = untrailingslashit(__FILE__).'\inc\cherki_hamza_plugin_activate.php';
echo '<center>';
echo $path;
echo '</center>'; */
}
function register(){
// initialize the custom post type
$this->create_custom_post_type(__FILE__);
// enqueue the admin backend scripts and styles
add_action( 'admin_enqueue_scripts', [$this , 'enqueue_admin_plugins'] );
// enqueue the frontend scrips and styles
add_action( 'wp_enqueue_scripts', [$this , 'enqueue_frontend_plugins'] );
// add Admin Menu in dashboard
add_action( 'admin_menu', [$this , 'add_admin_pages' ]);
// add link setting for the plugin
add_filter("plugin_action_links_$this->plugin", [$this, 'settings_link']);
}
// the setting link function
function settings_link($links){
$settings_link = '<a href="admin.php?page=cherki_hamza_plugin" >Settings</a>';
array_push($links , $settings_link );
return $links;
}
// function to add admin pages
public function add_admin_pages(){
add_menu_page('Cherki Hamza Plugin', 'CherkiHamza','manage_options','cherki_hamza_plugin' ,
[$this,'admin_index'],'dashicons-store',110);
}
// function for get the admin pages index
public function admin_index(){
require_once untrailingslashit(plugin_dir_path(__FILE__)).'\templates\admin-page.php';
}
protected function create_custom_post_type(){
add_action('init', array($this, 'custom_post_type'));
}
function custom_post_type(){
register_post_type( 'book' , ['public' => true , 'label'=>'Books'] );
register_post_type( 'product' , ['public' => true , 'label'=>'Products'] );
}
function enqueue_admin_plugins(){
wp_enqueue_style('my_bootstrap_style' , plugins_url('/assets/css/bootstrap.min.css', __FILE__ ));
wp_enqueue_style('my_style' , plugins_url('/assets/css/mystyle.css', __FILE__ ));
wp_enqueue_script('my_bootstrap_script', plugins_url('/assets/js/bootstrap.min.js', __FILE__));
}
function enqueue_frontend_plugins(){
wp_enqueue_style('my_frontend_style' , plugins_url('/assets/css/frontend.css', __FILE__ ));
wp_enqueue_style('my_bootstrap_style' , plugins_url('/assets/css/bootstrap.min.css', __FILE__ ));
wp_enqueue_script('my_bootstrap_script', plugins_url('/assets/js/bootstrap.min.js', __FILE__));
}
function activate(){
Activate::activate();
}
public static function print(){
echo '<center>';
echo 'just test test';
echo '</center>';
}
function deactivate(){
Deactivate::deactivate();
}
} // end of class
}// end if of class_exists
$cherki_hamza_dev = new Cherki_Hamza_Plugin();
$cherki_hamza_dev->register();
/* $cherki_hamza_dev::print(); */
// activation
/* $path = untrailingslashit(plugin_dir_path(__FILE__)).'\inc\cherki_hamza_plugin_activate.php';
*/
//register_activation_hook(plugin_dir_path(__FILE__) , ['Activate', 'activate']);
register_activation_hook( __FILE__ , [$cherki_hamza_dev, 'activate']);
// deactivation
register_deactivation_hook(plugin_dir_path(__FILE__), [ 'Deactivate', 'deactivate' ]);
//register_deactivation_hook( __FILE__, [ $cherki_hamza_dev, 'deactivate' ] );