Post Grid - Version 2.0.60

Version Description

  • 2020-05-24 add - addon "Search & Filter" added
    • 2020-05-24 add - addon "Post/Page Templates" added
    • 2020-05-29 add - import layouts notice added.
Download this release

Release Info

Developer pickplugins
Plugin Icon 128x128 Post Grid
Version 2.0.60
Comparing to
See all releases

Code changes from version 2.0.59 to 2.0.60

assets/admin/css/addons.css ADDED
@@ -0,0 +1,46 @@
1
+ @charset "utf-8";
2
+ /* CSS Document */
3
+
4
+
5
+
6
+ .addon-list{}
7
+ .addon-list a{
8
+ text-decoration: none;
9
+ }
10
+ .addon-list .item{
11
+ display: inline-block;
12
+ width: 280px;
13
+ overflow: hidden;
14
+ padding: 10px;
15
+ background: #fff;
16
+ margin: 15px;
17
+ box-shadow: 0 0 3px 0px rgba(193, 193, 193, 0.5);
18
+ vertical-align: top;
19
+ }
20
+
21
+ .addon-list .addon-title{}
22
+
23
+
24
+ .addon-list .thumb-wrap{
25
+
26
+ }
27
+ .addon-list .thumb-wrap img{
28
+ width: 100%;
29
+ }
30
+
31
+
32
+ .addon-list .addon-title{
33
+ margin: 10px 0;
34
+ font-size: 17px;
35
+ }
36
+ .addon-list .addon-link a{
37
+ text-decoration: none;
38
+ }
39
+
40
+ .addon-list .addon-link{}
41
+
42
+
43
+
44
+
45
+
46
+
assets/admin/images/post-templates.png ADDED
Binary file
assets/admin/images/pro.png ADDED
Binary file
assets/admin/images/search.png ADDED
Binary file
assets/admin/js/jquery.lazy.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! jQuery & Zepto Lazy v1.7.10 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2018 Daniel 'Eisbehr' Kern */
2
+ !function(t,e){"use strict";function r(r,a,i,u,l){function f(){L=t.devicePixelRatio>1,i=c(i),a.delay>=0&&setTimeout(function(){s(!0)},a.delay),(a.delay<0||a.combined)&&(u.e=v(a.throttle,function(t){"resize"===t.type&&(w=B=-1),s(t.all)}),u.a=function(t){t=c(t),i.push.apply(i,t)},u.g=function(){return i=n(i).filter(function(){return!n(this).data(a.loadedName)})},u.f=function(t){for(var e=0;e<t.length;e++){var r=i.filter(function(){return this===t[e]});r.length&&s(!1,r)}},s(),n(a.appendScroll).on("scroll."+l+" resize."+l,u.e))}function c(t){var i=a.defaultImage,o=a.placeholder,u=a.imageBase,l=a.srcsetAttribute,f=a.loaderAttribute,c=a._f||{};t=n(t).filter(function(){var t=n(this),r=m(this);return!t.data(a.handledName)&&(t.attr(a.attribute)||t.attr(l)||t.attr(f)||c[r]!==e)}).data("plugin_"+a.name,r);for(var s=0,d=t.length;s<d;s++){var A=n(t[s]),g=m(t[s]),h=A.attr(a.imageBaseAttribute)||u;g===N&&h&&A.attr(l)&&A.attr(l,b(A.attr(l),h)),c[g]===e||A.attr(f)||A.attr(f,c[g]),g===N&&i&&!A.attr(E)?A.attr(E,i):g===N||!o||A.css(O)&&"none"!==A.css(O)||A.css(O,"url('"+o+"')")}return t}function s(t,e){if(!i.length)return void(a.autoDestroy&&r.destroy());for(var o=e||i,u=!1,l=a.imageBase||"",f=a.srcsetAttribute,c=a.handledName,s=0;s<o.length;s++)if(t||e||A(o[s])){var g=n(o[s]),h=m(o[s]),b=g.attr(a.attribute),v=g.attr(a.imageBaseAttribute)||l,p=g.attr(a.loaderAttribute);g.data(c)||a.visibleOnly&&!g.is(":visible")||!((b||g.attr(f))&&(h===N&&(v+b!==g.attr(E)||g.attr(f)!==g.attr(F))||h!==N&&v+b!==g.css(O))||p)||(u=!0,g.data(c,!0),d(g,h,v,p))}u&&(i=n(i).filter(function(){return!n(this).data(c)}))}function d(t,e,r,i){++z;var o=function(){y("onError",t),p(),o=n.noop};y("beforeLoad",t);var u=a.attribute,l=a.srcsetAttribute,f=a.sizesAttribute,c=a.retinaAttribute,s=a.removeAttribute,d=a.loadedName,A=t.attr(c);if(i){var g=function(){s&&t.removeAttr(a.loaderAttribute),t.data(d,!0),y(T,t),setTimeout(p,1),g=n.noop};t.off(I).one(I,o).one(D,g),y(i,t,function(e){e?(t.off(D),g()):(t.off(I),o())})||t.trigger(I)}else{var h=n(new Image);h.one(I,o).one(D,function(){t.hide(),e===N?t.attr(C,h.attr(C)).attr(F,h.attr(F)).attr(E,h.attr(E)):t.css(O,"url('"+h.attr(E)+"')"),t[a.effect](a.effectTime),s&&(t.removeAttr(u+" "+l+" "+c+" "+a.imageBaseAttribute),f!==C&&t.removeAttr(f)),t.data(d,!0),y(T,t),h.remove(),p()});var m=(L&&A?A:t.attr(u))||"";h.attr(C,t.attr(f)).attr(F,t.attr(l)).attr(E,m?r+m:null),h.complete&&h.trigger(D)}}function A(t){var e=t.getBoundingClientRect(),r=a.scrollDirection,n=a.threshold,i=h()+n>e.top&&-n<e.bottom,o=g()+n>e.left&&-n<e.right;return"vertical"===r?i:"horizontal"===r?o:i&&o}function g(){return w>=0?w:w=n(t).width()}function h(){return B>=0?B:B=n(t).height()}function m(t){return t.tagName.toLowerCase()}function b(t,e){if(e){var r=t.split(",");t="";for(var a=0,n=r.length;a<n;a++)t+=e+r[a].trim()+(a!==n-1?",":"")}return t}function v(t,e){var n,i=0;return function(o,u){function l(){i=+new Date,e.call(r,o)}var f=+new Date-i;n&&clearTimeout(n),f>t||!a.enableThrottle||u?l():n=setTimeout(l,t-f)}}function p(){--z,i.length||z||y("onFinishedAll")}function y(t,e,n){return!!(t=a[t])&&(t.apply(r,[].slice.call(arguments,1)),!0)}var z=0,w=-1,B=-1,L=!1,T="afterLoad",D="load",I="error",N="img",E="src",F="srcset",C="sizes",O="background-image";"event"===a.bind||o?f():n(t).on(D+"."+l,f)}function a(a,o){var u=this,l=n.extend({},u.config,o),f={},c=l.name+"-"+ ++i;return u.config=function(t,r){return r===e?l[t]:(l[t]=r,u)},u.addItems=function(t){return f.a&&f.a("string"===n.type(t)?n(t):t),u},u.getItems=function(){return f.g?f.g():{}},u.update=function(t){return f.e&&f.e({},!t),u},u.force=function(t){return f.f&&f.f("string"===n.type(t)?n(t):t),u},u.loadAll=function(){return f.e&&f.e({all:!0},!0),u},u.destroy=function(){return n(l.appendScroll).off("."+c,f.e),n(t).off("."+c),f={},e},r(u,l,a,f,c),l.chainable?a:u}var n=t.jQuery||t.Zepto,i=0,o=!1;n.fn.Lazy=n.fn.lazy=function(t){return new a(this,t)},n.Lazy=n.lazy=function(t,r,i){if(n.isFunction(r)&&(i=r,r=[]),n.isFunction(i)){t=n.isArray(t)?t:[t],r=n.isArray(r)?r:[r];for(var o=a.prototype.config,u=o._f||(o._f={}),l=0,f=t.length;l<f;l++)(o[t[l]]===e||n.isFunction(o[t[l]]))&&(o[t[l]]=i);for(var c=0,s=r.length;c<s;c++)u[r[c]]=t[0]}},a.prototype.config={name:"lazy",chainable:!0,autoDestroy:!0,bind:"load",threshold:500,visibleOnly:!1,appendScroll:t,scrollDirection:"both",imageBase:null,defaultImage:"data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",placeholder:null,delay:-1,combined:!1,attribute:"data-src",srcsetAttribute:"data-srcset",sizesAttribute:"data-sizes",retinaAttribute:"data-retina",loaderAttribute:"data-loader",imageBaseAttribute:"data-imagebase",removeAttribute:!0,handledName:"handled",loadedName:"loaded",effect:"show",effectTime:0,enableThrottle:!0,throttle:250,beforeLoad:e,afterLoad:e,onError:e,onFinishedAll:e},n(t).on("load",function(){o=!0})}(window);
assets/admin/js/scripts.js CHANGED
@@ -41,6 +41,48 @@ jQuery(document).ready(function($){
41
}
42
});
43
})
44
});
45
46
41
}
42
});
43
})
44
+
45
+
46
+ $(document).on('click', '.post-grid-import-layouts', function(event){
47
+
48
+ event.preventDefault();
49
+
50
+ xml_source = $(this).attr('href');
51
+ $(this).html('Please wait...');
52
+
53
+
54
+ console.log(xml_source);
55
+
56
+ jQuery.ajax(
57
+ {
58
+ type: 'POST',
59
+ context: this,
60
+ url: post_grid_ajax.post_grid_ajaxurl,
61
+ data: {"action": "post_grid_import_xml_layouts","source": xml_source },
62
+ success: function(response) {
63
+ var data = JSON.parse( response );
64
+
65
+ success = data['success'];
66
+
67
+ $(this).html(success);
68
+
69
+ console.log(success);
70
+
71
+ }
72
+ });
73
+
74
+ })
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
});
87
88
assets/settings-tabs/settings-tabs.js CHANGED
@@ -145,6 +145,8 @@ jQuery(document).ready(function($){
145
side_uploader.open();
146
147
})
148
$(document).on('click','.settings-tabs .field-media-url-wrapper .clear',function(e){
149
$(this).parent().children('.media-preview-wrap').children('img').attr('src','');
150
$(this).parent().children('input').val('');
@@ -185,7 +187,6 @@ jQuery(document).ready(function($){
185
})
186
187
188
-
189
jQuery(document).on("click", ".settings-tabs .field-repeatable-wrapper .collapsible .header .title-text", function() {
190
if(jQuery(this).parent().parent().hasClass("active")){
191
jQuery(this).parent().parent().removeClass("active");
@@ -294,10 +295,22 @@ jQuery(document).ready(function($){
294
295
})
296
297
298
299
300
301
-
302
303
});
145
side_uploader.open();
146
147
})
148
+
149
+
150
$(document).on('click','.settings-tabs .field-media-url-wrapper .clear',function(e){
151
$(this).parent().children('.media-preview-wrap').children('img').attr('src','');
152
$(this).parent().children('input').val('');
187
})
188
189
190
jQuery(document).on("click", ".settings-tabs .field-repeatable-wrapper .collapsible .header .title-text", function() {
191
if(jQuery(this).parent().parent().hasClass("active")){
192
jQuery(this).parent().parent().removeClass("active");
295
296
})
297
298
+ // radio-img
299
300
+ $(document).on("click", ".radio-img label", function () {
301
+ if($(this).hasClass('disabled')){
302
+ return;
303
+ }
304
305
+ $(this).parent().children("label").removeClass("active");
306
+ $(this).addClass("active");
307
+
308
+ })
309
+
310
+ $(function() {
311
+ $('.lazy').Lazy();
312
+ });
313
314
315
316
});
includes/classes/class-admin-notices.php ADDED
@@ -0,0 +1,38 @@
1
+ <?php
2
+ if ( ! defined('ABSPATH')) exit; // if direct access
3
+
4
+ class class_post_grid_notices{
5
+
6
+ public function __construct(){
7
+
8
+ add_action('admin_notices', array( $this, 'import_layouts' ));
9
+
10
+ }
11
+
12
+ public function import_layouts(){
13
+
14
+ $post_grid_info = get_option('post_grid_info');
15
+ $import_layouts = isset($post_grid_info['import_layouts']) ? $post_grid_info['import_layouts'] : '';
16
+
17
+
18
+ //delete_option('post_grid_info');
19
+
20
+ ob_start();
21
+
22
+ if($import_layouts != 'done'):
23
+ ?>
24
+ <div class="update-nag">
25
+ <?php
26
+ echo sprintf(__('Post grid require import free layouts, please <a href="%s">click here</a> to go import page', 'post-grid-pro'), admin_url().'edit.php?post_type=post_grid&page=post-grid-settings&tab=help_support')
27
+ ?>
28
+ </div>
29
+ <?php
30
+ endif;
31
+
32
+
33
+ echo ob_get_clean();
34
+ }
35
+
36
+ }
37
+
38
+ new class_post_grid_notices();
includes/classes/class-functions.php CHANGED
@@ -53,7 +53,17 @@ class class_post_grid_functions{
53
return apply_filters('post_grid_post_status', $args);
54
}
55
56
57
58
public function media_source(){
59
53
return apply_filters('post_grid_post_status', $args);
54
}
55
56
+ function addons_list(){
57
58
+ $args['pro'] = array('title' => __('Post Grid Pro','post-grid'), 'thumb'=> post_grid_plugin_url.'assets/admin/images/pro.png', 'item_link' => 'https://www.pickplugins.com/item/post-grid-create-awesome-grid-from-any-post-type-for-wordpress/?ref=dashboard');
59
+
60
+ $args['search'] = array('title' => __('Search & Filter','post-grid'), 'thumb'=> post_grid_plugin_url.'assets/admin/images/search.png', 'item_link' => 'https://github.com/pickplugins/post-grid-search');
61
+ $args['post-templates'] = array('title' => __('Post/Page Templates','post-grid'), 'thumb'=>post_grid_plugin_url.'assets/admin/images/post-templates.png', 'item_link' => 'https://github.com/pickplugins/post-grid-post-templates');
62
+
63
+
64
+
65
+ return apply_filters('post_grid_extensions', $args);
66
+ }
67
68
public function media_source(){
69
includes/classes/class-meta-boxes.php CHANGED
@@ -592,19 +592,6 @@ class post_grid_meta_boxs{
592
'priority' => 1,
593
'active' => ($current_tab == 'options') ? true : false,
594
);
595
- // $post_grid_settings_tab[] = array(
596
- // 'id' => 'layouts',
597
- // 'title' => sprintf(__('%s Layouts','post-grid'), '<i class="fas fa-qrcode"></i>'),
598
- // 'priority' => 2,
599
- // 'active' => ($current_tab == 'layouts') ? true : false,
600
- // );
601
- // $post_grid_settings_tab[] = array(
602
- // 'id' => 'post_template',
603
- // 'title' => sprintf(__('%s Post template','post-grid'), '<i class="fas fa-newspaper"></i>'),
604
- // 'priority' => 2,
605
- // 'active' => ($current_tab == 'post_template') ? true : false,
606
- // );
607
-
608
609
610
$post_grid_settings_tabs = apply_filters('post_grid_post_options_tabs', $post_grid_settings_tab);
592
'priority' => 1,
593
'active' => ($current_tab == 'options') ? true : false,
594
);
595
596
597
$post_grid_settings_tabs = apply_filters('post_grid_post_options_tabs', $post_grid_settings_tab);
includes/classes/class-post-types.php CHANGED
@@ -98,10 +98,11 @@ class class_post_grid_post_types{
98
'exclude_from_search' => false,
99
'hierarchical' => false,
100
'query_var' => true,
101
- 'supports' => array( 'title' ),
102
'show_in_nav_menus' => false,
103
'show_in_menu' => 'edit.php?post_type=post_grid',
104
'menu_icon' => 'dashicons-businessman',
105
106
) )
107
);
98
'exclude_from_search' => false,
99
'hierarchical' => false,
100
'query_var' => true,
101
+ 'supports' => array( 'title' ), // 'editor'
102
'show_in_nav_menus' => false,
103
'show_in_menu' => 'edit.php?post_type=post_grid',
104
'menu_icon' => 'dashicons-businessman',
105
+ //'show_in_rest' => true,
106
107
) )
108
);
includes/classes/class-settings-tabs.php CHANGED
@@ -36,6 +36,9 @@ class settings_tabs_field{
36
wp_enqueue_script( 'code-editor' );
37
wp_enqueue_style( 'code-editor' );
38
39
wp_enqueue_editor();
40
}
41
@@ -1581,7 +1584,7 @@ class settings_tabs_field{
1581
if(!empty($thumb)):
1582
1583
?>
1584
- <img alt="<?php echo $name; ?>" src="<?php echo $thumb; ?>">
1585
<div style="padding: 5px;" class="name"><?php echo $name; ?></div>
1586
1587
<?php
@@ -1603,19 +1606,6 @@ class settings_tabs_field{
1603
endforeach;
1604
?>
1605
</div>
1606
- <script>
1607
- jQuery(document).ready(function($){
1608
- $(document).on("click", ".radio-img label", function () {
1609
- if($(this).hasClass('disabled')){
1610
- return;
1611
- }
1612
-
1613
- $(this).parent().children("label").removeClass("active");
1614
- $(this).addClass("active");
1615
-
1616
- })
1617
- })
1618
- </script>
1619
1620
<style type="text/css">
1621
.radio-img{}
36
wp_enqueue_script( 'code-editor' );
37
wp_enqueue_style( 'code-editor' );
38
39
+ wp_enqueue_script( 'jquery.lazy' );
40
+
41
+
42
wp_enqueue_editor();
43
}
44
1584
if(!empty($thumb)):
1585
1586
?>
1587
+ <img class="lazy" alt="<?php echo $name; ?>" data-src="<?php echo $thumb; ?>" src="https://i.imgur.com/72Z8sfU.gif">
1588
<div style="padding: 5px;" class="name"><?php echo $name; ?></div>
1589
1590
<?php
1606
endforeach;
1607
?>
1608
</div>
1609
1610
<style type="text/css">
1611
.radio-img{}
includes/classes/class-settings.php CHANGED
@@ -19,7 +19,6 @@ class class_post_grid_settings{
19
public function post_grid_menu_init() {
20
21
$post_grid_info = get_option('post_grid_info');
22
- $import_layouts = isset($post_grid_info['import_layouts']) ? $post_grid_info['import_layouts'] : '';
23
24
25
$data_update_status = isset($post_grid_info['data_update_status']) ? $post_grid_info['data_update_status'] : 'pending';
@@ -28,9 +27,7 @@ class class_post_grid_settings{
28
add_submenu_page('edit.php?post_type=post_grid', __('Layout Editor(Old)', 'post-grid'), __('Layout Editor(Old)', 'post-grid'), 'manage_options', 'layout_editor', array( $this, 'layout_editor' ));
29
30
add_submenu_page('edit.php?post_type=post_grid', __('Settings', 'post-grid'), __('Settings', 'post-grid'), 'manage_options', 'post-grid-settings', array( $this, 'settings' ));
31
-
32
- if($import_layouts != 'done')
33
- add_submenu_page( 'edit.php?post_type=post_grid', __( 'Import layouts', 'post-grid' ), __( 'Import layouts', 'post-grid' ), 'manage_options', 'import_layouts', array( $this, 'import_layouts' ) );
34
35
if($data_update_status == 'pending'):
36
add_submenu_page('edit.php?post_type=post_grid', __('Data Update', 'post-grid'), __('Data Update', 'post-grid'), 'manage_options', 'data-update', array( $this, 'data_update' ));
@@ -46,7 +43,9 @@ class class_post_grid_settings{
46
include(post_grid_plugin_dir.'includes/menu/settings.php');
47
}
48
49
-
50
public function layout_editor(){
51
include(post_grid_plugin_dir.'includes/menu/layout-editor.php');
52
}
19
public function post_grid_menu_init() {
20
21
$post_grid_info = get_option('post_grid_info');
22
23
24
$data_update_status = isset($post_grid_info['data_update_status']) ? $post_grid_info['data_update_status'] : 'pending';
27
add_submenu_page('edit.php?post_type=post_grid', __('Layout Editor(Old)', 'post-grid'), __('Layout Editor(Old)', 'post-grid'), 'manage_options', 'layout_editor', array( $this, 'layout_editor' ));
28
29
add_submenu_page('edit.php?post_type=post_grid', __('Settings', 'post-grid'), __('Settings', 'post-grid'), 'manage_options', 'post-grid-settings', array( $this, 'settings' ));
30
+ add_submenu_page('edit.php?post_type=post_grid', __('Addons', 'post-grid'), __('Addons', 'post-grid'), 'manage_options', 'post-grid-addons', array( $this, 'addons' ));
31
32
if($data_update_status == 'pending'):
33
add_submenu_page('edit.php?post_type=post_grid', __('Data Update', 'post-grid'), __('Data Update', 'post-grid'), 'manage_options', 'data-update', array( $this, 'data_update' ));
43
include(post_grid_plugin_dir.'includes/menu/settings.php');
44
}
45
46
+ public function addons(){
47
+ include(post_grid_plugin_dir.'includes/menu/addons.php');
48
+ }
49
public function layout_editor(){
50
include(post_grid_plugin_dir.'includes/menu/layout-editor.php');
51
}
includes/functions-data-upgrade.php CHANGED
@@ -1232,4 +1232,91 @@ function post_grid_layout_css($layout){
1232
1233
}
1234
1235
1232
1233
}
1234
1235
+ add_shortcode('post_grid_import_xml_layouts', 'post_grid_import_xml_layouts');
1236
1237
+ function post_grid_import_xml_layouts(){
1238
+
1239
+ $response = array();
1240
+ $user_id = get_current_user_id();
1241
+ $source = sanitize_text_field($_POST['source']);
1242
+ //$xml_source = 'http://localhost/wp/wp-content/plugins/post-grid/sample-data/post-grid-layouts.json';
1243
+
1244
+
1245
+
1246
+
1247
+ $json_obj = file_get_contents($source);
1248
+
1249
+ //$xml_json = json_encode($html_obj);
1250
+ $xml_arr = json_decode($json_obj, true);
1251
+
1252
+
1253
+ $items = $xml_arr['rss']['channel']['item'];
1254
+
1255
+ foreach ($items as $item){
1256
+
1257
+ $post_title = isset($item['title']) ? $item['title'] : '';
1258
+ $postmeta = isset($item['postmeta']) ? $item['postmeta'] : array();
1259
+
1260
+ $post_id = wp_insert_post(
1261
+ array(
1262
+ 'post_title' => $post_title,
1263
+ 'post_content' => '',
1264
+ 'post_status' => 'draft',
1265
+ 'post_type' => 'post_grid_layout',
1266
+ 'post_author' => $user_id,
1267
+ )
1268
+ );
1269
+
1270
+ // echo '<br>';
1271
+ // echo $post_title. ' Created';
1272
+ // echo '<br>';
1273
+
1274
+
1275
+ foreach ($postmeta as $meta){
1276
+
1277
+ $meta_key = isset($meta['meta_key']['__cdata']) ? $meta['meta_key']['__cdata'] : '';
1278
+ $meta_value = isset($meta['meta_value']['__cdata']) ? $meta['meta_value']['__cdata'] : '';
1279
+
1280
+ // echo '<br>';
1281
+ // //var_dump(unserialize($meta_value));
1282
+ // echo '<br>';
1283
+
1284
+
1285
+
1286
+ if($meta_key == 'layout_options' || $meta_key == 'layout_elements_data' || $meta_key == 'custom_scripts' ){
1287
+ //var_dump($meta_value);
1288
+
1289
+ update_post_meta($post_id, $meta_key, unserialize($meta_value));
1290
+ }
1291
+
1292
+
1293
+ }
1294
+
1295
+
1296
+
1297
+
1298
+ }
1299
+
1300
+
1301
+ $response['success'] = __('Import done','post-grid');
1302
+
1303
+ $post_grid_info = get_option('post_grid_info');
1304
+
1305
+ if(strpos($source, 'post-grid-pro')){
1306
+ $post_grid_info['import_pro_layouts'] = 'done';
1307
+ }else{
1308
+ $post_grid_info['import_layouts'] = 'done';
1309
+ }
1310
+
1311
+
1312
+ update_option('post_grid_info', $post_grid_info);
1313
+
1314
+
1315
+
1316
+ echo json_encode($response);
1317
+ die();
1318
+
1319
+
1320
+ }
1321
+
1322
+ add_action('wp_ajax_post_grid_import_xml_layouts', 'post_grid_import_xml_layouts');
includes/functions-single.php DELETED
@@ -1,130 +0,0 @@
1
- <?php
2
- if ( ! defined('ABSPATH')) exit; // if direct access
3
-
4
- //add_action('the_content','post_grid_single_post');
5
-
6
- function post_grid_single_post($content){
7
-
8
- $post_id = get_the_id();
9
- $post_grid_post_settings = get_post_meta($post_id,'post_grid_post_settings', true);
10
-
11
- $layout_id = !empty($post_grid_post_settings['layout_id']) ? (int) $post_grid_post_settings['layout_id'] : '';
12
-
13
- //var_dump($layout_id);
14
-
15
- if(!empty($layout_id)){
16
-
17
-
18
- $layout_elements_data = get_post_meta( $layout_id, 'layout_elements_data', true );
19
- $layout_custom_scripts = get_post_meta($layout_id,'custom_scripts', true);
20
- $layout_custom_css = isset($layout_custom_scripts['custom_css']) ? $layout_custom_scripts['custom_css'] : '';
21
-
22
- ob_start();
23
-
24
- ?>
25
- <div class="layout-<?php echo $layout_id; ?>">
26
- <?php
27
-
28
- if(!empty($layout_elements_data))
29
- foreach($layout_elements_data as $elementIndex=>$elementData){
30
- foreach($elementData as $elementId=>$element) {
31
-
32
- //var_dump($elementId);
33
-
34
- $element_args['element'] = $element;
35
- $element_args['index'] = $elementIndex;
36
-
37
- $element_args['post_id'] = $post_id;
38
- $element_args['layout_id'] = $layout_id;
39
-
40
- do_action('post_grid_layout_element_' . $elementId, $element_args);
41
- do_action('post_grid_layout_element_css_' . $elementId, $element_args);
42
-
43
-
44
-
45
- }
46
-
47
- }
48
- ?>
49
- </div>
50
- <?php if(!empty($layout_custom_css)): ?>
51
- <style type="text/css">
52
- <?php
53
- echo str_replace('__ID__', 'layout-'.$layout_id, $layout_custom_css);
54
- ?>
55
- </style>
56
- <?php endif; ?>
57
- <?php
58
- $content = ob_get_clean();
59
-
60
- }
61
-
62
-
63
- return $content;
64
-
65
- }
66
-
67
-
68
-
69
-
70
-
71
- function post_grid_remove_post_title($post_title){
72
-
73
- $post_id = get_the_ID();
74
-
75
- $post_grid_post_settings = get_post_meta($post_id, 'post_grid_post_settings', true);
76
- $remove_post_title = isset($post_grid_post_settings['remove_post_title']) ? $post_grid_post_settings['remove_post_title'] : 'no';
77
-
78
-
79
- if($remove_post_title =='yes' && in_the_loop()){
80
-
81
- return '';
82
- }
83
- else{
84
- return $post_title;
85
- }
86
-
87
- }
88
-
89
- //add_filter('the_title','post_grid_remove_post_title');
90
-
91
-
92
- function post_grid_remove_post_thumbnail($post_thumbnail){
93
-
94
- $post_id = get_the_ID();
95
-
96
- $post_grid_post_settings = get_post_meta($post_id, 'post_grid_post_settings', true);
97
- $remove_post_thumbnail = isset($post_grid_post_settings['remove_post_thumbnail']) ? $post_grid_post_settings['remove_post_thumbnail'] : 'no';
98
-
99
-
100
- if(is_singular() && $remove_post_thumbnail == 'yes'){
101
-
102
- return '';
103
- }
104
- else{
105
- return $post_thumbnail;
106
- }
107
-
108
- }
109
-
110
- //add_filter('post_thumbnail_html','post_grid_remove_post_thumbnail');
111
-
112
-
113
- function post_grid_single_template($single_template) {
114
- global $post;
115
-
116
- if ($post->post_type == 'post') {
117
-
118
- $single_template = post_grid_plugin_dir . 'templates/single/single-template-hook.php';
119
-
120
- }
121
- return $single_template;
122
- }
123
- //add_filter( 'single_template', 'post_grid_single_template' );
124
-
125
-
126
-
127
-
128
-
129
-
130
-
includes/layout-elements/3rd-party.php CHANGED
@@ -72,14 +72,14 @@ if ( is_plugin_active( 'page-visit-counter/page-visit-counter.php' ) ) {
72
73
74
75
- if ( is_plugin_active( 'wck-custom-fields-and-custom-post-types-creator/wck.php' ) ) {
76
77
require_once( post_grid_plugin_dir . 'includes/layout-elements/wck-custom-fields-and-custom-post-types-creator/layout-elements.php');
78
}
79
80
81
82
- if ( is_plugin_active( 'wp-job-manager/wp-job-manager.php' ) ) {
83
84
require_once( post_grid_plugin_dir . 'includes/layout-elements/wp-job-manager/layout-elements.php');
85
}
72
73
74
75
+ if ( is_plugin_active( 'wck-custom-fields-and-custom-post-types-creator/wck.php' ) ){
76
77
require_once( post_grid_plugin_dir . 'includes/layout-elements/wck-custom-fields-and-custom-post-types-creator/layout-elements.php');
78
}
79
80
81
82
+ if ( is_plugin_active( 'wp-job-manager/wp-job-manager.php' ) ){
83
84
require_once( post_grid_plugin_dir . 'includes/layout-elements/wp-job-manager/layout-elements.php');
85
}
includes/layout-elements/simple-job-board/layout-elements.php ADDED
@@ -0,0 +1,2646 @@
1
+ <?php
2
+ if ( ! defined('ABSPATH')) exit; // if direct access
3
+
4
+ add_filter('post_grid_layout_elements','post_grid_simplejobboard_layout_elements', 5);
5
+
6
+ function post_grid_simplejobboard_layout_elements($elements_group){
7
+
8
+ $elements_group['simplejobboard'] = array(
9
+ 'group_title'=>'Simple Job Board',
10
+ 'items'=>array(
11
+ 'simplejobboard_job_expires'=>array('name' =>__('Job expire date','post-grid')),
12
+ 'simplejobboard_category'=>array('name' =>__('Category','post-grid')),
13
+ 'simplejobboard_job_type'=>array('name' =>__('Job type','post-grid')),
14
+ 'simplejobboard_job_feature'=>array('name' =>__('Job feature','post-grid')),
15
+
16
+ 'simplejobboard_location'=>array('name' =>__('Location','post-grid')),
17
+ 'simplejobboard_company_name'=>array('name' =>__('Company name','post-grid')),
18
+ 'simplejobboard_company_website'=>array('name' =>__('Company website','post-grid')),
19
+ 'simplejobboard_company_tagline'=>array('name' =>__('Company tagline','post-grid')),
20
+ 'simplejobboard_company_logo'=>array('name' =>__('Company logo','post-grid')),
21
+
22
+
23
+ ),
24
+ );
25
+
26
+ return $elements_group;
27
+ }
28
+
29
+
30
+
31
+
32
+
33
+ add_action('post_grid_layout_element_option_simplejobboard_location','post_grid_layout_element_option_simplejobboard_location');
34
+ function post_grid_layout_element_option_simplejobboard_location($parameters){
35
+
36
+ $settings_tabs_field = new settings_tabs_field();
37
+
38
+ $input_name = isset($parameters['input_name']) ? $parameters['input_name'] : '{input_name}';
39
+ $element_data = isset($parameters['element_data']) ? $parameters['element_data'] : array();
40
+ $element_index = isset($parameters['index']) ? $parameters['index'] : '';
41
+
42
+
43
+ $max_count = isset($element_data['max_count']) ? $element_data['max_count'] : '';
44
+ $separator = isset($element_data['separator']) ? $element_data['separator'] : '';
45
+ $link_color = isset($element_data['link_color']) ? $element_data['link_color'] : '';
46
+
47
+ $color = isset($element_data['color']) ? $element_data['color'] : '';
48
+ $font_size = isset($element_data['font_size']) ? $element_data['font_size'] : '';
49
+ $font_family = isset($element_data['font_family']) ? $element_data['font_family'] : '';
50
+ $margin = isset($element_data['margin']) ? $element_data['margin'] : '';
51
+ $text_align = isset($element_data['text_align']) ? $element_data['text_align'] : '';
52
+ $wrapper_html = !empty($element_data['wrapper_html']) ? $element_data['wrapper_html'] : '%s';
53
+
54
+ $css = isset($element_data['css']) ? $element_data['css'] : '';
55
+ $css_hover = isset($element_data['css_hover']) ? $element_data['css_hover'] : '';
56
+
57
+
58
+
59
+ ?>
60
+ <div class="item">
61
+ <div class="element-title header ">
62
+ <span class="remove" onclick="jQuery(this).parent().parent().remove()"><i class="fas fa-times"></i></span>
63
+ <span class="sort"><i class="fas fa-sort"></i></span>
64
+
65
+ <span class="expand"><?php echo __('Location','post-grid'); ?></span>
66
+ </div>
67
+ <div class="element-options options">
68
+
69
+ <?php
70
+
71
+ $args = array(
72
+ 'id' => 'max_count',
73
+ 'parent' => $input_name.'[simplejobboard_location]',
74
+ 'title' => __('Max count','post-grid'),
75
+ 'details' => __('Write max count','post-grid'),
76
+ 'type' => 'text',
77
+ 'value' => $max_count,
78
+ 'default' => 3,
79
+ 'placeholder' => '3',
80
+ );
81
+
82
+ $settings_tabs_field->generate_field($args);
83
+
84
+ $args = array(
85
+ 'id' => 'separator',
86
+ 'css_id' => $element_index.'_separator',
87
+ 'parent' => $input_name.'[simplejobboard_location]',
88
+ 'title' => __('Link separator','post-grid'),
89
+ 'details' => __('Choose link separator.','post-grid'),
90
+ 'type' => 'text',
91
+ 'value' => $separator,
92
+ 'default' => '',
93
+ 'placeholder' => ', ',
94
+
95
+ );
96
+
97
+ $settings_tabs_field->generate_field($args);
98
+
99
+ $args = array(
100
+ 'id' => 'wrapper_html',
101
+ 'css_id' => $element_index.'_wrapper_html',
102
+ 'parent' => $input_name.'[simplejobboard_location]',
103
+ 'title' => __('Wrapper html','post-grid'),
104
+ 'details' => __('Write wrapper html, use <code>%s</code> to replace output. ex: <code>Location: %s</code>','post-grid'),
105
+ 'type' => 'text',
106
+ 'value' => $wrapper_html,
107
+ 'default' => '',
108
+ 'placeholder' => 'Location: %s',
109
+ );
110
+
111
+ $settings_tabs_field->generate_field($args);
112
+
113
+ $args = array(
114
+ 'id' => 'link_color',
115
+ 'css_id' => $element_index.'_link_color',
116
+ 'parent' => $input_name.'[simplejobboard_location]',
117
+ 'title' => __('Link color','post-grid'),
118
+ 'details' => __('Choose link color.','post-grid'),
119
+ 'type' => 'colorpicker',
120
+ 'value' => $link_color,
121
+ 'default' => '',
122
+ );
123
+
124
+ $settings_tabs_field->generate_field($args);
125
+
126
+ $args = array(
127
+ 'id' => 'color',
128
+ 'css_id' => $element_index.'_color',
129
+ 'parent' => $input_name.'[simplejobboard_location]',
130
+ 'title' => __('Text Color','post-grid'),
131
+ 'details' => __('Choose text color.','post-grid'),
132
+ 'type' => 'colorpicker',
133
+ 'value' => $color,
134
+ 'default' => '',
135
+ );
136
+
137
+ $settings_tabs_field->generate_field($args);
138
+
139
+ $args = array(
140
+ 'id' => 'font_size',
141
+ 'css_id' => $element_index.'_font_size',
142
+ 'parent' => $input_name.'[simplejobboard_location]',
143
+ 'title' => __('Font size','post-grid'),
144
+ 'details' => __('Set font size.','post-grid'),
145
+ 'type' => 'text',
146
+ 'value' => $font_size,
147
+ 'default' => '',
148
+ 'placeholder' => '14px',
149
+ );
150
+
151
+ $settings_tabs_field->generate_field($args);
152
+
153
+
154
+ $args = array(
155
+ 'id' => 'font_family',
156
+ 'css_id' => $element_index.'_font_family',
157
+ 'parent' => $input_name.'[simplejobboard_location]',
158
+ 'title' => __('Font family','post-grid'),
159
+ 'details' => __('Set font family.','post-grid'),
160
+ 'type' => 'text',
161
+ 'value' => $font_family,
162
+ 'default' => '',
163
+ 'placeholder' => 'Open Sans',
164
+ );
165
+
166
+ $settings_tabs_field->generate_field($args);
167
+
168
+
169
+ $args = array(
170
+ 'id' => 'margin',
171
+ 'css_id' => $element_index.'_margin',
172
+ 'parent' => $input_name.'[simplejobboard_location]',
173
+ 'title' => __('Margin','post-grid'),
174
+ 'details' => __('Set margin.','post-grid'),
175
+ 'type' => 'text',
176
+ 'value' => $margin,
177
+ 'default' => '',
178
+ 'placeholder' => '5px 0',
179
+ );
180
+
181
+ $settings_tabs_field->generate_field($args);
182
+
183
+
184
+ $args = array(
185
+ 'id' => 'text_align',
186
+ 'css_id' => $element_index.'_text_align',
187
+ 'parent' => $input_name.'[simplejobboard_location]',
188
+ 'title' => __('Text align','post-grid'),
189
+ 'details' => __('Choose text align.','post-grid'),
190
+ 'type' => 'select',
191
+ 'value' => $text_align,
192
+ 'default' => 'left',
193
+ 'args' => array('left'=> __('Left', 'post-grid'),'right'=> __('Right', 'post-grid'),'center'=> __('Center', 'post-grid') ),
194
+ );
195
+
196
+ $settings_tabs_field->generate_field($args);
197
+
198
+
199
+ $args = array(
200
+ 'id' => 'css',
201
+ 'css_id' => $element_index.'_css',
202
+ 'parent' => $input_name.'[simplejobboard_location]',
203
+ 'title' => __('Custom CSS','post-grid'),
204
+ 'details' => __('Set csutom CSS.','post-grid'),
205
+ 'type' => 'textarea',
206
+ 'value' => $css,
207
+ 'default' => '',
208
+ 'placeholder' => '',
209
+ );
210
+
211
+ $settings_tabs_field->generate_field($args);
212
+
213
+ $args = array(
214
+ 'id' => 'css_hover',
215
+ 'css_id' => $element_index.'_css_hover',
216
+ 'parent' => $input_name.'[simplejobboard_location]',
217
+ 'title' => __('Hover CSS','post-grid'),
218
+ 'details' => __('Set hover custom CSS.','post-grid'),
219
+ 'type' => 'textarea',
220
+ 'value' => $css_hover,
221
+ 'default' => '',
222
+ 'placeholder' => '',
223
+ );
224
+
225
+ $settings_tabs_field->generate_field($args);
226
+
227
+
228
+ ob_start();
229
+ ?>
230
+ <textarea readonly type="text" onclick="this.select();">.element_<?php echo $element_index?>{}</textarea>
231
+ <?php
232
+
233
+ $html = ob_get_clean();
234
+
235
+ $args = array(
236
+ 'id' => 'use_css',
237
+ 'title' => __('Use of CSS','post-grid'),
238
+ 'details' => __('Use following class selector to add custom CSS for this element.','post-grid'),
239
+ 'type' => 'custom_html',
240
+ 'html' => $html,
241
+
242
+ );
243
+
244
+ $settings_tabs_field->generate_field($args);
245
+
246
+ ?>
247
+
248
+ </div>
249
+ </div>
250
+ <?php
251
+
252
+ }
253
+
254
+
255
+
256
+
257
+ add_action('post_grid_layout_element_simplejobboard_location', 'post_grid_layout_element_simplejobboard_location');
258
+
259
+ function post_grid_layout_element_simplejobboard_location($args){
260
+
261
+ $element = isset($args['element']) ? $args['element'] : array();
262
+ $elementIndex = isset($args['index']) ? $args['index'] : '';
263
+ $post_id = isset($args['post_id']) ? $args['post_id'] : '';
264
+
265
+ if(empty($post_id)) return;
266
+
267
+ $custom_class = isset($element['custom_class']) ? $element['custom_class'] : '';
268
+ $link_target = isset($element['link_target']) ? $element['link_target'] : '';
269
+ $max_count = isset($element['max_count']) ? (int) $element['max_count'] : 3;
270
+ $wrapper_html = !empty($element['wrapper_html']) ? $element['wrapper_html'] : '%s';
271
+ $separator = isset($element['separator']) ? $element['separator'] : ', ';
272
+
273
+
274
+ $term_list = wp_get_post_terms( $post_id, 'jobpost_location', array( 'fields' => 'all' ) );
275
+
276
+ $categories_html = '';
277
+ $term_total_count = count($term_list);
278
+ $max_term_limit = ($term_total_count < $max_count) ? $term_total_count : $max_count ;
279
+
280
+ $i = 0;
281
+ foreach ($term_list as $term){
282
+ if($i >= $max_count) continue;
283
+
284
+ $term_id = isset($term->term_id) ? $term->term_id : '';
285
+ $term_name = isset($term->name) ? $term->name : '';
286
+ $term_link = get_term_link($term_id);
287
+
288
+ $categories_html .= '<a target="'.esc_attr($link_target).'" href="'.esc_url_raw($term_link).'">'.esc_html($term_name).'</a>';
289
+ if( $i+1 < $max_term_limit){ $categories_html .= $separator;}
290
+
291
+ $i++;
292
+ }
293
+
294
+
295
+ ?>
296
+ <div class="element element_<?php echo esc_attr($elementIndex); ?> <?php echo esc_attr($custom_class); ?> categories ">
297
+ <?php echo sprintf($wrapper_html, $categories_html); ?>
298
+ </div>
299
+ <?php
300
+ }
301
+
302
+
303
+
304
+
305
+
306
+ add_action('post_grid_layout_element_css_simplejobboard_location', 'post_grid_layout_element_css_simplejobboard_location', 10);
307
+ function post_grid_layout_element_css_simplejobboard_location($args){
308
+
309
+
310
+ $index = isset($args['index']) ? $args['index'] : '';
311
+ $element = isset($args['element']) ? $args['element'] : array();
312
+ $layout_id = isset($args['layout_id']) ? $args['layout_id'] : '';
313
+
314
+ $link_color = isset($element['link_color']) ? $element['link_color'] : '';
315
+ $text_color = isset($element['text_color']) ? $element['text_color'] : '';
316
+
317
+ $font_size = isset($element['font_size']) ? $element['font_size'] : '';
318
+ $font_family = isset($element['font_family']) ? $element['font_family'] : '';
319
+ $margin = isset($element['margin']) ? $element['margin'] : '';
320
+ $text_align = isset($element['text_align']) ? $element['text_align'] : '';
321
+ $css = isset($element['css']) ? $element['css'] : '';
322
+ $css_hover = isset($element['css_hover']) ? $element['css_hover'] : '';
323
+ ?>
324
+ <style type="text/css">
325
+ .layout-<?php echo $layout_id; ?> .element_<?php echo $index; ?>{
326
+ <?php if(!empty($text_color)): ?>
327
+ color: <?php echo $text_color; ?>;
328
+ <?php endif; ?>
329
+ <?php if(!empty($font_size)): ?>
330
+ font-size: <?php echo $font_size; ?>;
331
+ <?php endif; ?>
332
+ <?php if(!empty($font_family)): ?>
333
+ font-family: <?php echo $font_family; ?>;
334
+ <?php endif; ?>
335
+ <?php if(!empty($margin)): ?>
336
+ margin: <?php echo $margin; ?>;
337
+ <?php endif; ?>
338
+ <?php if(!empty($text_align)): ?>
339
+ text-align: <?php echo $text_align; ?>;
340
+ <?php endif; ?>
341
+ <?php if(!empty($css)): ?>
342
+ <?php echo $css; ?>
343
+ <?php endif; ?>
344
+ }
345
+ .layout-<?php echo $layout_id; ?> .element_<?php echo $index; ?> a{
346
+ <?php if(!empty($link_color)): ?>
347
+ color: <?php echo $link_color; ?>;
348
+ <?php endif; ?>
349
+ <?php if(!empty($font_size)): ?>
350
+ font-size: <?php echo $font_size; ?>;
351
+ <?php endif; ?>
352
+ <?php if(!empty($font_family)): ?>
353
+ font-family: <?php echo $font_family; ?>;
354
+ <?php endif; ?>
355
+ }
356
+ <?php if(!empty($css_hover)): ?>
357
+ .layout-<?php echo $layout_id; ?> .element_<?php echo $index; ?>:hover{
358
+ <?php echo $css_hover; ?>
359
+ }
360
+ <?php endif; ?>
361
+ </style>
362
+ <?php
363
+ }
364
+
365
+
366
+ add_action('post_grid_layout_element_option_simplejobboard_category','post_grid_layout_element_option_simplejobboard_category');
367
+ function post_grid_layout_element_option_simplejobboard_category($parameters){
368
+
369
+ $settings_tabs_field = new settings_tabs_field();
370
+
371
+ $input_name = isset($parameters['input_name']) ? $parameters['input_name'] : '{input_name}';
372
+ $element_data = isset($parameters['element_data']) ? $parameters['element_data'] : array();
373
+ $element_index = isset($parameters['index']) ? $parameters['index'] : '';
374
+
375
+
376
+ $max_count = isset($element_data['max_count']) ? $element_data['max_count'] : '';
377
+ $separator = isset($element_data['separator']) ? $element_data['separator'] : '';
378
+ $link_color = isset($element_data['link_color']) ? $element_data['link_color'] : '';
379
+
380
+ $color = isset($element_data['color']) ? $element_data['color'] : '';
381
+ $font_size = isset($element_data['font_size']) ? $element_data['font_size'] : '';
382
+ $font_family = isset($element_data['font_family']) ? $element_data['font_family'] : '';
383
+ $margin = isset($element_data['margin']) ? $element_data['margin'] : '';
384
+ $text_align = isset($element_data['text_align']) ? $element_data['text_align'] : '';
385
+ $wrapper_html = !empty($element_data['wrapper_html']) ? $element_data['wrapper_html'] : '%s';
386
+
387
+ $css = isset($element_data['css']) ? $element_data['css'] : '';
388
+ $css_hover = isset($element_data['css_hover']) ? $element_data['css_hover'] : '';
389
+
390
+
391
+
392
+ ?>
393
+ <div class="item">
394
+ <div class="element-title header ">
395
+ <span class="remove" onclick="jQuery(this).parent().parent().remove()"><i class="fas fa-times"></i></span>
396
+ <span class="sort"><i class="fas fa-sort"></i></span>
397
+
398
+ <span class="expand"><?php echo __('Categories','post-grid'); ?></span>
399
+ </div>
400
+ <div class="element-options options">
401
+
402
+ <?php
403
+
404
+ $args = array(
405
+ 'id' => 'max_count',
406
+ 'parent' => $input_name.'[simplejobboard_category]',
407
+ 'title' => __('Max count','post-grid'),
408
+ 'details' => __('Write max count','post-grid'),
409
+ 'type' => 'text',
410
+ 'value' => $max_count,
411
+ 'default' => 3,
412
+ 'placeholder' => '3',
413
+ );
414
+
415
+ $settings_tabs_field->generate_field($args);
416
+
417
+ $args = array(
418
+ 'id' => 'separator',
419
+ 'css_id' => $element_index.'_separator',
420
+ 'parent' => $input_name.'[simplejobboard_category]',
421
+ 'title' => __('Link separator','post-grid'),
422
+ 'details' => __('Choose link separator.','post-grid'),
423
+ 'type' => 'text',
424
+ 'value' => $separator,
425
+ 'default' => '',
426
+ 'placeholder' => ', ',
427
+
428
+ );
429
+
430
+ $settings_tabs_field->generate_field($args);
431
+
432
+ $args = array(
433
+ 'id' => 'wrapper_html',
434
+ 'css_id' => $element_index.'_wrapper_html',
435
+ 'parent' => $input_name.'[simplejobboard_category]',
436
+ 'title' => __('Wrapper html','post-grid'),
437
+ 'details' => __('Write wrapper html, use <code>%s</code> to replace output. ex: <code>Categories: %s</code>','post-grid'),
438
+ 'type' => 'text',
439
+ 'value' => $wrapper_html,
440
+ 'default' => '',
441
+ 'placeholder' => 'Location: %s',
442
+ );
443
+
444
+ $settings_tabs_field->generate_field($args);
445
+
446
+ $args = array(
447
+ 'id' => 'link_color',
448
+ 'css_id' => $element_index.'_link_color',
449
+ 'parent' => $input_name.'[simplejobboard_category]',
450
+ 'title' => __('Link color','post-grid'),
451
+ 'details' => __('Choose link color.','post-grid'),
452
+ 'type' => 'colorpicker',
453
+ 'value' => $link_color,
454
+ 'default' => '',
455
+ );
456
+
457
+ $settings_tabs_field->generate_field($args);
458
+
459
+ $args = array(
460
+ 'id' => 'color',
461
+ 'css_id' => $element_index.'_color',
462
+ 'parent' => $input_name.'[simplejobboard_category]',
463
+ 'title' => __('Text Color','post-grid'),
464
+ 'details' => __('Choose text color.','post-grid'),
465
+ 'type' => 'colorpicker',
466
+ 'value' => $color,
467
+ 'default' => '',
468
+ );
469
+
470
+ $settings_tabs_field->generate_field($args);
471
+
472
+ $args = array(
473
+ 'id' => 'font_size',
474
+ 'css_id' => $element_index.'_font_size',
475
+ 'parent' => $input_name.'[simplejobboard_category]',
476
+ 'title' => __('Font size','post-grid'),
477
+ 'details' => __('Set font size.','post-grid'),
478
+ 'type' => 'text',
479
+ 'value' => $font_size,
480
+ 'default' => '',
481
+ 'placeholder' => '14px',
482
+ );
483
+
484
+ $settings_tabs_field->generate_field($args);
485
+
486
+
487
+ $args = array(
488
+ 'id' => 'font_family',
489
+ 'css_id' => $element_index.'_font_family',
490
+ 'parent' => $input_name.'[simplejobboard_category]',
491
+ 'title' => __('Font family','post-grid'),
492
+ 'details' => __('Set font family.','post-grid'),
493
+ 'type' => 'text',
494
+ 'value' => $font_family,
495
+ 'default' => '',
496
+ 'placeholder' => 'Open Sans',
497
+ );
498
+
499
+ $settings_tabs_field->generate_field($args);
500
+
501
+
502
+ $args = array(
503
+ 'id' => 'margin',
504
+ 'css_id' => $element_index.'_margin',
505
+ 'parent' => $input_name.'[simplejobboard_category]',
506
+ 'title' => __('Margin','post-grid'),
507
+ 'details' => __('Set margin.','post-grid'),
508
+ 'type' => 'text',
509
+ 'value' => $margin,
510
+ 'default' => '',
511
+ 'placeholder' => '5px 0',
512
+ );
513
+
514
+ $settings_tabs_field->generate_field($args);
515
+
516
+
517
+ $args = array(
518
+ 'id' => 'text_align',
519
+ 'css_id' => $element_index.'_text_align',
520
+ 'parent' => $input_name.'[simplejobboard_category]',
521
+ 'title' => __('Text align','post-grid'),
522
+ 'details' => __('Choose text align.','post-grid'),
523
+ 'type' => 'select',
524
+ 'value' => $text_align,
525
+ 'default' => 'left',
526
+ 'args' => array('left'=> __('Left', 'post-grid'),'right'=> __('Right', 'post-grid'),'center'=> __('Center', 'post-grid') ),
527
+ );
528
+
529
+ $settings_tabs_field->generate_field($args);
530
+
531
+
532
+ $args = array(
533
+ 'id' => 'css',
534
+ 'css_id' => $element_index.'_css',
535
+ 'parent' => $input_name.'[simplejobboard_category]',
536
+ 'title' => __('Custom CSS','post-grid'),
537
+ 'details' => __('Set csutom CSS.','post-grid'),
538
+ 'type' => 'textarea',
539
+ 'value' => $css,
540
+ 'default' => '',
541
+ 'placeholder' => '',
542
+ );
543
+
544
+ $settings_tabs_field->generate_field($args);
545
+
546
+ $args = array(
547
+ 'id' => 'css_hover',
548
+ 'css_id' => $element_index.'_css_hover',
549
+ 'parent' => $input_name.'[simplejobboard_category]',
550
+ 'title' => __('Hover CSS','post-grid'),
551
+ 'details' => __('Set hover custom CSS.','post-grid'),
552
+ 'type' => 'textarea',
553
+ 'value' => $css_hover,
554
+ 'default' => '',
555
+ 'placeholder' => '',
556
+ );
557
+
558
+ $settings_tabs_field->generate_field($args);
559
+
560
+
561
+ ob_start();
562
+ ?>
563
+ <textarea readonly type="text" onclick="this.select();">.element_<?php echo $element_index?>{}</textarea>
564
+ <?php
565
+
566
+ $html = ob_get_clean();
567
+
568
+ $args = array(
569
+ 'id' => 'use_css',
570
+ 'title' => __('Use of CSS','post-grid'),
571
+ 'details' => __('Use following class selector to add custom CSS for this element.','post-grid'),
572
+ 'type' => 'custom_html',
573
+ 'html' => $html,
574
+
575
+ );
576
+
577
+ $settings_tabs_field->generate_field($args);
578
+
579
+ ?>
580
+
581
+ </div>
582
+ </div>
583
+ <?php
584
+
585
+ }
586
+
587
+
588
+
589
+
590
+ add_action('post_grid_layout_element_simplejobboard_category', 'post_grid_layout_element_simplejobboard_category');
591
+
592
+ function post_grid_layout_element_simplejobboard_category($args){
593
+
594
+ $element = isset($args['element']) ? $args['element'] : array();
595
+ $elementIndex = isset($args['index']) ? $args['index'] : '';
596
+ $post_id = isset($args['post_id']) ? $args['post_id'] : '';
597
+
598
+ if(empty($post_id)) return;
599
+
600
+ $custom_class = isset($element['custom_class']) ? $element['custom_class'] : '';
601
+ $link_target = isset($element['link_target']) ? $element['link_target'] : '';
602
+ $max_count = isset($element['max_count']) ? (int) $element['max_count'] : 3;
603
+ $wrapper_html = !empty($element['wrapper_html']) ? $element['wrapper_html'] : '%s';
604
+ $separator = isset($element['separator']) ? $element['separator'] : ', ';
605
+
606
+
607
+ $term_list = wp_get_post_terms( $post_id, 'jobpost_category', array( 'fields' => 'all' ) );
608
+
609
+ $categories_html = '';
610
+ $term_total_count = count($term_list);
611
+ $max_term_limit = ($term_total_count < $max_count) ? $term_total_count : $max_count ;
612
+
613
+ $i = 0;
614
+ foreach ($term_list as $term){
615
+ if($i >= $max_count) continue;
616
+
617
+ $term_id = isset($term->term_id) ? $term->term_id : '';
618
+ $term_name = isset($term->name) ? $term->name : '';
619
+ $term_link = get_term_link($term_id);
620
+
621
+ $categories_html .= '<a target="'.esc_attr($link_target).'" href="'.esc_url_raw($term_link).'">'.esc_html($term_name).'</a>';
622
+ if( $i+1 < $max_term_limit){ $categories_html .= $separator;}
623
+
624
+ $i++;
625
+ }
626
+
627
+
628
+ ?>
629
+ <div class="element element_<?php echo esc_attr($elementIndex); ?> <?php echo esc_attr($custom_class); ?> categories ">
630
+ <?php echo sprintf($wrapper_html, $categories_html); ?>
631
+ </div>
632
+ <?php
633
+ }
634
+
635
+
636
+
637
+
638
+
639
+ add_action('post_grid_layout_element_css_simplejobboard_category', 'post_grid_layout_element_css_simplejobboard_category', 10);
640
+ function post_grid_layout_element_css_simplejobboard_category($args){
641
+
642
+
643
+ $index = isset($args['index']) ? $args['index'] : '';
644
+ $element = isset($args['element']) ? $args['element'] : array();
645
+ $layout_id = isset($args['layout_id']) ? $args['layout_id'] : '';
646
+
647
+ $link_color = isset($element['link_color']) ? $element['link_color'] : '';
648
+ $text_color = isset($element['text_color']) ? $element['text_color'] : '';
649
+
650
+ $font_size = isset($element['font_size']) ? $element['font_size'] : '';
651
+ $font_family = isset($element['font_family']) ? $element['font_family'] : '';
652
+ $margin = isset($element['margin']) ? $element['margin'] : '';
653
+ $text_align = isset($element['text_align']) ? $element['text_align'] : '';
654
+ $css = isset($element['css']) ? $element['css'] : '';
655
+ $css_hover = isset($element['css_hover']) ? $element['css_hover'] : '';
656
+ ?>
657
+ <style type="text/css">
658
+ .layout-<?php echo $layout_id; ?> .element_<?php echo $index; ?>{
659
+ <?php if(!empty($text_color)): ?>
660
+ color: <?php echo $text_color; ?>;
661
+ <?php endif; ?>
662
+ <?php if(!empty($font_size)): ?>
663
+ font-size: <?php echo $font_size; ?>;
664
+ <?php endif; ?>
665
+ <?php if(!empty($font_family)): ?>
666
+ font-family: <?php echo $font_family; ?>;
667
+ <?php endif; ?>
668
+ <?php if(!empty($margin)): ?>
669
+ margin: <?php echo $margin; ?>;
670
+ <?php endif; ?>
671
+ <?php if(!empty($text_align)): ?>
672
+ text-align: <?php echo $text_align; ?>;
673
+ <?php endif; ?>
674
+ <?php if(!empty($css)): ?>
675
+ <?php echo $css; ?>