PluginProbe
Post Grid Gutenberg Blocks – PostX / 1.2.2
Post Grid Gutenberg Blocks – PostX v1.2.2
5.0.39 5.0.38 5.0.37 5.0.36 5.0.35 5.0.34 5.0.33 5.0.32 5.0.31 5.0.30 5.0.29 5.0.28 5.0.27 5.0.26 5.0.25 5.0.23 5.0.24 5.0.22 5.0.21 5.0.20 5.0.19 5.0.18 5.0.17 2.1.1 2.1.2 All 237 releases
← All changes | classes/Functions.php +15 -162 2.1.21.2.2 View file →
@@ -4,143 +4,19 @@
4 4 defined('ABSPATH') || exit;
5 5
6 6 class Functions{
7 7
8 - public function __construct(){
9 - $GLOBALS['ultp_settings'] = get_option('ultp_options');
10 - }
11 -
12 - public function reusable_id($post_id){
13 - $reusable_id = array();
14 - if($post_id){
15 - $post = get_post($post_id);
16 - if (has_blocks($post->post_content)) {
17 - $blocks = parse_blocks($post->post_content);
18 - foreach ($blocks as $key => $value) {
19 - if(isset($value['attrs']['ref'])) {
20 - $reusable_id[] = $value['attrs']['ref'];
21 - }
22 - }
23 - }
24 - }
25 - return $reusable_id;
26 - }
27 -
28 - public function set_css_style($post_id){
29 - if( $post_id ){
30 - $upload_dir_url = wp_get_upload_dir();
31 - $upload_css_dir_url = trailingslashit( $upload_dir_url['basedir'] );
32 - $css_dir_path = $upload_css_dir_url . "ultimate-post/ultp-css-{$post_id}.css";
33 -
34 - $css_dir_url = trailingslashit( $upload_dir_url['baseurl'] );
35 - if (is_ssl()) {
36 - $css_dir_url = str_replace('http://', 'https://', $css_dir_url);
37 - }
38 -
39 - // Reusable CSS
40 - $reusable_id = ultimate_post()->reusable_id($post_id);
41 - foreach ( $reusable_id as $id ) {
42 - $reusable_dir_path = $upload_css_dir_url."ultimate-post/ultp-css-{$id}.css";
43 - if (file_exists( $reusable_dir_path )) {
44 - $css_url = $css_dir_url . "ultimate-post/ultp-css-{$id}.css";
45 - wp_enqueue_style( "ultp-post-{$id}", $css_url, array(), ULTP_VER, 'all' );
46 - }else{
47 - $css = get_post_meta($id, '_ultp_css', true);
48 - if( $css ) {
49 - wp_enqueue_style("ultp-post-{$id}", $css, false, ULTP_VER);
50 - }
51 - }
52 - }
53 -
54 - if ( file_exists( $css_dir_path ) ) {
55 - $css_url = $css_dir_url . "ultimate-post/ultp-css-{$post_id}.css";
56 - wp_enqueue_style( "ultp-post-{$post_id}", $css_url, array(), ULTP_VER, 'all' );
57 - } else {
58 - $css = get_post_meta($post_id, '_ultp_css', true);
59 - if( $css ) {
60 - wp_enqueue_style("ultp-post-{$post_id}", $css, false, ULTP_VER);
61 - }
62 - }
63 - }
64 - }
65 -
66 - public function get_setting($key = ''){
67 - $data = $GLOBALS['ultp_settings'];
68 - if ($key != '') {
69 - return isset($data[$key]) ? $data[$key] : '';
70 - } else {
71 - return $data;
72 - }
73 - }
74 -
75 - public function set_setting($key = '', $val = '') {
76 - if($key != ''){
77 - $data = $GLOBALS['ultp_settings'];
78 - $data[$key] = $val;
79 - update_option('ultp_options', $data);
80 - $GLOBALS['ultp_settings'] = $data;
81 - }
82 - }
83 -
84 - public function get_image_html($url = '', $size = 'full', $class = '', $alt = ''){
85 - $alt = $alt ? ' alt="'.$alt.'" ' : '';
86 - if( function_exists('ultimate_post_pro') ){
87 - $addon_enable = ultimate_post()->get_setting();
88 - if(isset($addon_enable['addons_imageloading']) && $addon_enable['addons_imageloading'] == 'true'){
89 - $class = $class ? ' class="ultp-lazy '.$class.'" ' : ' class="ultp-lazy" ';
90 - return '<img loading="lazy" loading="lazy" '.$class.$alt.' '.ultimate_post_pro()->get_size($size).' src="'.ultimate_post_pro()->img_placeholder($size).'" data-src="'.$url.'"/>';
91 - }else{
92 - $class = $class ? ' class="'.$class.'" ' : '';
93 - return '<img loading="lazy" '.$class.$alt.' src="'.$url.'" />';
94 - }
95 - } else {
96 - $class = $class ? ' class="'.$class.'" ' : '';
97 - return '<img loading="lazy" '.$class.$alt.' src="'.$url.'" />';
98 - }
99 - }
100 -
101 - public function get_image($attach_id, $size = 'full', $class = '', $alt = ''){
102 - $alt = $alt ? ' alt="'.$alt.'" ' : '';
103 - if( function_exists('ultimate_post_pro') ){
104 - $addon_enable = ultimate_post()->get_setting();
105 - if(isset($addon_enable['addons_imageloading']) && $addon_enable['addons_imageloading'] == 'true'){
106 - $class = $class ? ' class="ultp-lazy '.$class.'" ' : ' class="ultp-lazy" ';
107 - return '<img loading="lazy" '.$class.$alt.' '.ultimate_post_pro()->get_size($size).' src="'.ultimate_post_pro()->img_placeholder($size).'" data-src="'.wp_get_attachment_image_url( $attach_id, $size ).'"/>';
108 - }else{
109 - $class = $class ? ' class="'.$class.'" ' : '';
110 - return '<img loading="lazy" '.$class.$alt.' src="'.wp_get_attachment_image_url( $attach_id, $size ).'" />';
111 - }
112 - } else {
113 - $class = $class ? ' class="'.$class.'" ' : '';
114 - return '<img loading="lazy" '.$class.$alt.' src="'.wp_get_attachment_image_url( $attach_id, $size ).'" />';
115 - }
116 - }
117 -
118 8 // Init data
119 9 public function init_set_data(){
120 - $data = get_option( 'ultp_options', array() );
121 - $init_data = array(
122 - 'css_save_as' => 'wp_head',
123 - 'preloader_style' => 'style1',
124 - 'preloader_color' => '#1740f5',
125 - 'container_width' => '1140',
126 - 'editor_container' => 'full_width',
127 - 'hide_import_btn' => '',
128 - 'ultp_templates' => 'true',
129 - 'ultp_elementor' => 'true'
10 + $option_data = array(
11 + 'css_save_as' => 'wp_head',
12 + 'preloader_style' => 'style1',
13 + 'preloader_color' => '#1740f5',
14 + 'container_width' => '1140',
15 + 'hide_import_btn' => ''
130 16 );
131 - if (empty($data)) {
132 - update_option('ultp_options', $init_data);
133 - $GLOBALS['wopb_settings'] = $init_data;
134 - } else {
135 - foreach ($init_data as $key => $single) {
136 - if (!isset($data[$key])) {
137 - $data[$key] = $single;
138 - }
139 - }
140 - update_option('ultp_options', $data);
141 - $GLOBALS['wopb_settings'] = $data;
142 - }
17 + update_option('ultp_options', $option_data);
18 + return $option_data;
143 19 }
144 20
145 21 // Excerpt
146 22 public function excerpt( $post_id, $limit = 55 ) {
@@ -163,12 +39,14 @@
163 39 $query_args['meta_key'] = $attr['metaKey'];
164 40 }
165 41 }
166 42
43 + if(isset($attr['queryOffset']) && $attr['queryOffset'] && !($query_args['paged'] > 1) ){
44 + $query_args['offset'] = isset($attr['queryOffset']) ? $attr['queryOffset'] : 0;
45 + }
46 +
167 47 if(isset($attr['queryInclude']) && $attr['queryInclude']){
168 48 $query_args['post__in'] = explode(',', $attr['queryInclude']);
169 - $query_args['ignore_sticky_posts'] = 1;
170 - $query_args['orderby'] = 'post__in';
171 49 }
172 50
173 51 if(isset($attr['queryExclude']) && $attr['queryExclude']){
174 52 $query_args['post__not_in'] = explode(',', $attr['queryExclude']);
@@ -180,15 +58,13 @@
180 58 $var = array('relation'=>'OR');
181 59 foreach (json_decode($attr['queryCat']) as $val) {
182 60 $var[] = array('taxonomy'=>'category', 'field' => 'slug', 'terms' => $val );
183 61 }
184 - if(count($var) > 1){
185 - $query_args['tax_query'] = $var;
186 - }
62 + $query_args['tax_query'] = $var;
187 63 }
188 64 }
189 65 if(isset($attr['queryTag'])){
190 - if($attr['queryTax'] == 'post_tag' && !empty($attr['queryTag'])){
66 + if($attr['queryTax'] == 'tag' && !empty($attr['queryTag'])){
191 67 $var = array('relation'=>'OR');
192 68 foreach (json_decode($attr['queryTag']) as $val) {
193 69 $var[] = array('taxonomy'=>'post_tag', 'field' => 'slug', 'terms' => $val );
194 70 }
@@ -196,31 +72,8 @@
196 72 }
197 73 }
198 74 }
199 75
200 - if(isset($attr['queryQuick'])){
201 - if($attr['queryQuick'] != ''){
202 - if(function_exists('ultimate_post_pro')){
203 - $query_args = ultimate_post_pro()->get_quick_query($attr, $query_args);
204 - }
205 - }
206 - }
207 -
208 - if(isset($attr['queryOffset']) && $attr['queryOffset'] ){
209 - if($query_args['paged'] > 1){
210 - $offset_post = wp_get_recent_posts($query_args, OBJECT);
211 - if( count($offset_post) > 0 ){
212 - $offset = array();
213 - for($x = count($offset_post); $x > count($offset_post) - $attr['queryOffset']; $x--){
214 - $offset[] = $offset_post[$x-1]->ID;
215 - }
216 - $query_args['post__not_in'] = $offset;
217 - }
218 - }else{
219 - $query_args['offset'] = isset($attr['queryOffset']) ? $attr['queryOffset'] : 0;
220 - }
221 - }
222 -
223 76 $query_args['wpnonce'] = wp_create_nonce( 'ultp-nonce' );
224 77
225 78 return $query_args;
226 79 }
@@ -352,9 +205,9 @@
352 205
353 206 public function loading(){
354 207 $html = '';
355 208 $style = 'style1';
356 - $option_data = ultimate_post()->get_setting();
209 + $option_data = get_option('ultp_options');
357 210 if( isset($option_data['preloader_style']) ){
358 211 $style = $option_data['preloader_style'];
359 212 }
360 213 if( $style == 'style2' ){