-
Notifications
You must be signed in to change notification settings - Fork 0
/
class-10 (theme structure).php
284 lines (188 loc) · 6.87 KB
/
class-10 (theme structure).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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
<?php
/*
Plugin Name: Stock Toolkit
*/
#widgests
//-----------------
add_action( 'init', 'my_theme_custom_post' );
function my_theme_custom_post() {
register_post_type( 'Testimonial',
array(
'labels' => array(
'name' => __( 'Testimonials' ),
'singular_name' => __( 'Testimonial' )
),
'supports' => array('title', 'editor', 'thumbnail', 'page-attributes'),
'public' => false,
'show_ui' => true, // if wnat to change the icon add menu icon option
)
);
}
#shortcodes
//---------------
function post_list_shortcode($atts){
extract( shortcode_atts( array(
'count' => -1, // if -1 then all post will come
'type' => 'post' ,
'color' => '#D54E21',
'icon' => ''
), $atts) );
$q = new WP_Query(
array('posts_per_page' => $count,
'post_type' => 'page',
'post_type' => $type
)
);
$list = '<ul>';
while($q->have_posts()) : $q->the_post();
$idd = get_the_ID();
$custom_field = get_post_meta($idd, 'custom_field', true);
$post_content = get_the_content();
// $list .= '<li><a style="'.$color.'" href="'.get_permalink().'">'.get_the_title().'</a></li>';
$list .= '<li><a style="color:'.$color.'" href="'.get_permalink().'">';
if(!empty($icon)){
$list .='<i class="'.$icon.'"></i>';
}
$list.=''.get_the_title().'</a></li>';
endwhile;
$list.= '</ul>';
wp_reset_query();
return $list;
}
add_shortcode('post_list', 'post_list_shortcode');
#vc_ADDons
//-----------------------
function stock_vc_postlist_addon(){
vc_map( array(
"name" => __( "Post list", "my-text-domain" ),
"base" => "post_list", // which shortcode do i want to integrate
// "class" => "",
"category" => __( "Stock", "my-text-domain"),
// 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'), // if we dont want css in admin
// 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
"params" => array(
array(
"type" => "dropdown",
//"holder" => "div",
//"class" => "",
"heading" => __( "Post type", "my-text-domain" ),
"param_name" => "type", // attributes name
"std" => "post", // attributes name
"value" => array( // if dropdown then it will change
"Page" => "page",
"Post" => "post",
), // default value // std dile def asbe
"description" => __( "Type post here", "my-text-domain" )
),
array(
"type" => "textfield",
"heading" => __( "Post count", "my-text-domain" ),
"param_name" => "count",
"value" => __( "-1", "my-text-domain" ),
"description" => __( "how many item do you want to show. -1 for unlimited ", "my-text-domain" ),
"dependency" => array(
"element"=> "type",
"value"=> "post" // if post then value -1 will appear
)
),
array(
"type" => "colorpicker",
"heading" => __( "Link color", "my-text-domain" ),
"param_name" => "color",
"value" => __( "#D54E21", "my-text-domain" ), // default value shold be in shordcode also
"description" => __( "Choose your color", "my-text-domain" )
),
array(
"type" => "vc_link",
"heading" => __( "Link color", "my-text-domain" ),
"param_name" => "color",
"description" => __( "Choose your color", "my-text-domain" )
),
array(
"type" => "iconpicker",
"heading" => __( "Icon", "my-text-domain" ),
"param_name" => "icon",
//"value" => __( "fa fa-link", "my-text-domain" ), // default value shold be in shordcode also
"description" => __( "Choose your icon very carefully ", "my-text-domain" )
)
)
)
);
}
add_action('vc_before_init','stock_vc_postlist_addon');
# stock-toolkit.php (sturctured)
//--------------------------------------
/*
Plugin Name: Stock Toolkit
*/
// Exit if accessed directly
if( ! defined('ABSPATH')){
exit;
}
//define
define('STOCK_ACC_URL',WP_PLUGIN_URL.'/'.plugin_basename(dirname(__FILE__)).'/');
define('STOCK_ACC_PATH',plugin_dir_path(__FILE__));
add_action( 'init', 'my_theme_custom_post' );
function my_theme_custom_post() {
register_post_type( 'Testimonial',
array(
'labels' => array(
'name' => __( 'Testimonials' ),
'singular_name' => __( 'Testimonial' )
),
'supports' => array('title', 'editor', 'thumbnail', 'page-attributes'),
'public' => false,
'show_ui' => true,
)
);
}
//Print Shortcodes in widgets
add_filter('widget_text','do_shortcode');
// Loading VC addons
//require_once(STOCK_ACC_PATH.'vc-addons/bc-blocks-load.php');
// Theme sortcodes
//require_once(STOCK_ACC_PATH.'theme-shortcodes/slides-shortcode.php');
// Shortcodes depended on vc
include_once(ABSPATH.'wp-admin/includes/plugin.php');
if(is_plugin_active('js_composer/js_composer.php')){
// require_once(STOCK_ACC_PATH. 'theme-shortcodes/staff-shortcode.php');
}
//Registering stock toolkit filesize
function stock_toollit_files(){
wp_enqueue_style('owl-carousel', plugin_dir_url(__FILE__).'assets/css/owl.carousel.css');
wp_enqueue_scripts('owl-carousel', plugin_dir_url(__FILE__).'assets/js/owl.carousel.min.js',array('jquery'),'232323', true);
}
add_action('wp_enqueue_scripts','stock_toollit_files');
# vc-blocks-load.php
//---------------------
<?php
if(!defined('ABSPATH')) die(-1);
// class started
class stockVCExtendAddonsClass{
function __construct(){
// we safely integrate with Vc with this hook
add_action('init',array($this,'stockIntegrateWithVC'));
}
public function stockIntegrateWithVC(){
// check if visula composer is not installed
if(!defined('WPB_VC_VERSION')){
add_action('admin_notices',array($this,'stockShowVvBersionNotice'));
return;
}
// vc addons
include STOCK_ACC_PATH.'/vc-addons/vc-slides.php';
}
//show vc versions
public function stockShowVvBersionNotice(){
$theme_data = wp_get_theme();
echo '
<div class="notice notice-warning">
<p>'.sprintf(__('<strong>%s</strong> recomends <strong><a href="'.site_url().'/wp-admin/theme.php?page=tgmpa-install-pluings" target="_blank"> Visula COmposer</a></strong> plugin to be installed and activated on your site.','stock-crazecafe'), $theme_data->get('name')).'</p>
</div>';
}
}
// Finally instialize code
new stockVCExtendAddonsClass();
?>
?>
?>