-
Notifications
You must be signed in to change notification settings - Fork 0
/
codexin-core.php
238 lines (210 loc) · 8.07 KB
/
codexin-core.php
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<?php
/*
Plugin Name: Codexin Core
Plugin URI: http://themeitems.com
Description: A plugin to carry out all the core functionalities for Codexin theme
Version: 1.0
Author: Themeitems
Author URI: http://themeitems.com
License: GPL2
Text Domain: codexin
*/
// Declaring Global Constants for plugin paths and URL
define( 'CODEXIN_CORE_VERSION', '1.0' );
define( 'CODEXIN_CORE_INC_DIR', plugin_dir_path( __FILE__ ) . 'inc' );
define( 'CODEXIN_CORE_ASSET_DIR', plugin_dir_url( __FILE__ ) . 'assets' );
define( 'CODEXIN_CORE_JS_DIR', CODEXIN_CORE_ASSET_DIR . '/js/shortcode-js' );
define( 'CODEXIN_CORE_SC_DIR', plugin_dir_path( __FILE__ ) . 'inc/shortcodes' );
define( 'CODEXIN_CORE_WDGT_DIR', plugin_dir_path( __FILE__ ) . 'inc/widgets' );
if( ! class_exists( 'Codexin_Core' ) ) {
/**
* Master class for the Codexin Core Plugin
*
* @since v1.0
*/
class Codexin_Core {
/**
* Call all loading functions.
*
* @since v1.0
*/
public function __construct() {
// Loading the core files
$this -> codexin_includes();
// Enquequeing styles and scripts
$this -> codexin_enqueque();
// Enquequeing admin styles and scripts
$this -> codexin_admin_enqueque();
// Register actions using add_actions() custom function.
$this -> codexin_add_actions();
}
/**
* Loading the core files
*
* @since v1.0
*/
public function codexin_includes() {
// Registering Custom Posts
require_once CODEXIN_CORE_INC_DIR . '/custompost.php';
// Adding metaboxes
require_once CODEXIN_CORE_INC_DIR . '/metaboxes.php';
// Registering and Integrating the Shortcodes in King Composer
// require_once CODEXIN_CORE_INC_DIR . '/shortcode_loader.php';
// Adding Helper File
require_once CODEXIN_CORE_INC_DIR . '/helpers.php';
// Including post like system
require_once CODEXIN_CORE_INC_DIR . '/post_like.php';
// Initalizing custom widgets
require_once CODEXIN_CORE_WDGT_DIR . '/address-box-widget.php';
require_once CODEXIN_CORE_WDGT_DIR . '/instagram-widget.php';
require_once CODEXIN_CORE_WDGT_DIR . '/popular-posts-widget.php';
require_once CODEXIN_CORE_WDGT_DIR . '/recent-posts-widget.php';
require_once CODEXIN_CORE_WDGT_DIR . '/social-share-widget.php';
}
/**
* Enqueques styles and scripts
*
* @since v1.0
*/
public function codexin_enqueque() {
add_action( 'wp_enqueue_scripts', array( $this, 'codexin_styles' ), 99 );
add_action( 'wp_enqueue_scripts', array( $this, 'codexin_script' ), 99 );
}
public function codexin_styles() {
wp_enqueue_style( 'swiper', CODEXIN_CORE_ASSET_DIR . '/css/swiper.min.css', false, '4.4.2','all' );
wp_enqueue_style( 'photoswipe', CODEXIN_CORE_ASSET_DIR . '/css/photoswipe.min.css', false, '4.1.2','all' );
}
public function codexin_script() {
wp_enqueue_script( 'swiper', CODEXIN_CORE_ASSET_DIR . '/js/swiper.min.js', array( 'jquery' ), 4.4, true );
wp_enqueue_script( 'photoswipe', CODEXIN_CORE_ASSET_DIR . '/js/photoswipe.js', array( 'jquery' ), 4.1, true );
wp_enqueue_script( 'codexin-post-like-script', CODEXIN_CORE_ASSET_DIR . '/js/codexin-post-like.js', array( 'jquery' ), '0.5', true );
wp_localize_script( 'codexin-post-like-script', 'postLikes', array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'like' => esc_html__( 'Like', 'codexin' ),
'unlike' => esc_html__( 'Unlike', 'codexin' )
) );
}
/**
* Enqueques admin styles and scripts
*
* @since v1.0
*/
public function codexin_admin_enqueque() {
add_action( 'admin_enqueue_scripts', array( $this, 'codexin_admin_styles' ), 99 );
}
public function codexin_admin_styles() {
wp_enqueue_style( 'codexin-admin-stylesheet', CODEXIN_CORE_ASSET_DIR . '/css/admin/admin-metabox-styles.css', false, '1.0','all' );
}
/**
* Add actions and filters in the plugin.
*
* @uses add_action()
* @uses add_filter()
* @since v1.0
*/
public function codexin_add_actions() {
/**
* Load plugin text domain.
*
* @since 1.0.0
*/
add_action( 'init', 'codexin_core_load_textdomain' );
function codexin_core_load_textdomain() {
load_plugin_textdomain( 'codexin-core', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
/**
* Adding custom image sizes.
*
* @since 1.0.0
*/
add_action( 'init', 'codexin_add_image_sizes' );
function codexin_add_image_sizes() {
add_image_size( 'codexin-core-rect-one', 600, 400, true );
add_image_size( 'codexin-core-rect-two', 570, 464, true );
add_image_size( 'codexin-core-square-one', 220, 220, true );
add_image_size( 'codexin-core-square-two', 500, 500, true );
}
/**
* Initialization of photoswipe
*
* @since v1.0
*/
add_action( 'wp_footer', 'codexin_photoswipe_init' );
function codexin_photoswipe_init() {
$result = '';
ob_start();
?>
<!-- Initializing Photoswipe -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
<div class="pswp__bg"></div>
<div class="pswp__scroll-wrap">
<div class="pswp__container">
<div class="pswp__item"></div>
<div class="pswp__item"></div>
<div class="pswp__item"></div>
</div>
<div class="pswp__ui pswp__ui--hidden">
<div class="pswp__top-bar">
<div class="pswp__counter"></div>
<button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
<button class="pswp__button pswp__button--share" title="Share"></button>
<button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
<button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
<div class="pswp__preloader">
<div class="pswp__preloader__icn">
<div class="pswp__preloader__cut">
<div class="pswp__preloader__donut"></div>
</div>
</div>
</div>
</div>
<div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
<div class="pswp__share-tooltip"></div>
</div>
<button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
</button>
<button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
</button>
<div class="pswp__caption">
<div class="pswp__caption__center"></div>
</div>
</div>
</div>
</div>
<!-- end of Photoswipe -->
<?php
$result .= ob_get_clean();
printf( '%s', $result );
}
}
}
}
// Instantiating the Master Class
$codexin_core = new Codexin_Core();
// add_filter('template_include', 'testimonial_archive_template');
// function testimonial_archive_template( $template ) {
// if ( is_post_type_archive('testimonial') ) {
// $theme_files = array('archive-testimonial.php', 'templates/archive-testimonial.php');
// $exists_in_theme = locate_template( $theme_files, false );
// if ( $exists_in_theme != '' ) {
// return $exists_in_theme;
// } else {
// return plugin_dir_path(__FILE__) . 'templates/archive-testimonial.php';
// }
// }
// return $template;
// }
// add_filter( 'single_template', 'testimonial_single_template', 10, 1 );
// function testimonial_single_template( $single_template ) {
// if ( is_singular('testimonial') ) {
// $theme_files = array('single-testimonial.php', 'templates/single-testimonial.php');
// $exists_in_theme = locate_template( $theme_files, false );
// if ( $exists_in_theme != '' ) {
// return $exists_in_theme;
// } else {
// return plugin_dir_path(__FILE__) . 'templates/single-testimonial.php';
// }
// }
// return $template;
// }
?>