Changeset 3221380
- Timestamp:
- 01/13/2025 07:57:01 AM (14 months ago)
- Location:
- quickcreator
- Files:
-
- 8 edited
- 5 copied
-
tags/0.0.3/includes/quickcreator/class-content-importer.php (modified) (25 diffs)
-
tags/0.1.2 (copied) (copied from quickcreator/trunk)
-
tags/0.1.2/includes/admin/class-quickcreator-admin.php (modified) (2 diffs)
-
tags/0.1.2/includes/quickcreator/class-content-importer.php (modified) (2 diffs)
-
tags/0.1.2/includes/quickcreator/class-quickcreator.php (copied) (copied from quickcreator/trunk/includes/quickcreator/class-quickcreator.php) (4 diffs)
-
tags/0.1.2/includes/quickcreator/content-parsers/class-gutenberg-parser.php (copied) (copied from quickcreator/trunk/includes/quickcreator/content-parsers/class-gutenberg-parser.php)
-
tags/0.1.2/quickcreator.php (copied) (copied from quickcreator/trunk/quickcreator.php) (2 diffs)
-
tags/0.1.2/readme.txt (copied) (copied from quickcreator/trunk/readme.txt) (1 diff)
-
trunk/includes/admin/class-quickcreator-admin.php (modified) (2 diffs)
-
trunk/includes/quickcreator/class-content-importer.php (modified) (2 diffs)
-
trunk/includes/quickcreator/class-quickcreator.php (modified) (4 diffs)
-
trunk/quickcreator.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
quickcreator/tags/0.0.3/includes/quickcreator/class-content-importer.php
r3142565 r3221380 1 1 <?php 2 2 3 /** 3 4 * Object that handle importing content from: … … 18 19 * Object that imports data from different sources into WordPress. 19 20 */ 20 class Content_Importer { 21 class Content_Importer 22 { 21 23 22 24 /** … … 31 33 * Basic construct. 32 34 */ 33 public function __construct() { 35 public function __construct() 36 { 34 37 $this->content_parser = new Parsers_Controller(); 35 38 } … … 43 46 * @return int|WP_Error 44 47 */ 45 public function save_data_into_database( $content, $args = array()) { 46 $user = get_users()[0]; 47 wp_set_current_user( $user->ID, $user->data->display_name); 48 if ( 'elementor' === $args['filter'] ) { 48 public function save_data_into_database($content, $args = array()) 49 { 50 $user_args = array( 51 'role' => 'Administrator', 52 'orderby' => 'user_nicename', 53 'order' => 'ASC', 54 ); 55 $user = get_users($user_args)[0]; 56 wp_set_current_user($user->ID, $user->data->display_name); 57 if ('elementor' === $args['filter']) { 49 58 $if_elementor_is_active = quickcreator_check_if_plugins_is_active('elementor/elementor.php'); 50 59 if ($if_elementor_is_active) { 51 60 $rawContent = ""; 52 61 } 53 } else if ( 'raw' !== $args['filter']) {54 $rawContent = $this->content_parser->parse_content( $content);62 } else if ('raw' !== $args['filter']) { 63 $rawContent = $this->content_parser->parse_content($content); 55 64 } else { 56 65 $this->content_parser->choose_parser(); 57 66 $rawContent = $content; 58 67 } 59 $title = isset( $args['post_title'] ) && strlen( $args['post_title']) > 0 ? $args['post_title'] : $this->content_parser->return_title();68 $title = isset($args['post_title']) && strlen($args['post_title']) > 0 ? $args['post_title'] : $this->content_parser->return_title(); 60 69 61 70 $data = array( … … 64 73 ); 65 74 66 if ( isset( $args['post_id'] ) && $args['post_id'] > 0) {75 if (isset($args['post_id']) && $args['post_id'] > 0) { 67 76 68 77 $provided_post_id = $args['post_id']; … … 75 84 } 76 85 77 $this->resolve_post_author( $args, $data);78 $this->resolve_post_status( $args, $data);79 $this->resolve_post_type( $args, $data);80 $this->resolve_post_permalink( $args, $data);81 $this->resolve_post_category( $args, $data);82 $this->resolve_post_tags( $args, $data);83 $this->resolve_post_meta_details( $args, $data);84 $this->resolve_post_excerpt( $args, $data);85 $this->resolve_post_parent( $args, $data);86 87 if ( isset( $post ) && 'published' === $post['post_status']) {86 $this->resolve_post_author($args, $data); 87 $this->resolve_post_status($args, $data); 88 $this->resolve_post_type($args, $data); 89 $this->resolve_post_permalink($args, $data); 90 $this->resolve_post_category($args, $data); 91 $this->resolve_post_tags($args, $data); 92 $this->resolve_post_meta_details($args, $data); 93 $this->resolve_post_excerpt($args, $data); 94 $this->resolve_post_parent($args, $data); 95 96 if (isset($post) && 'published' === $post['post_status']) { 88 97 // WordPress set current date as default and we do not want to change publication date. 89 98 $data['post_date'] = $post['post_date']; 90 99 } else { 91 $this->resolve_post_date( $args, $data);92 } 93 94 $post_id = wp_insert_post( $data, true);95 96 if ( ! is_wp_error( $post_id ) && isset( $args['draft_id'] )) {97 update_post_meta( $post_id, 'quickcreator_draft_id', $args['draft_id']);98 update_post_meta( $post_id, 'quickcreator_permalink_hash', isset( $args['permalink_hash'] ) ? $args['permalink_hash'] : '');99 update_post_meta( $post_id, 'quickcreator_keywords', $args['keywords']);100 update_post_meta( $post_id, 'quickcreator_location', $args['location']);101 update_post_meta( $post_id, 'quickcreator_scrape_ready', true);102 update_post_meta( $post_id, 'quickcreator_last_post_update', round( microtime( true ) * 1000 ));103 update_post_meta( $post_id, 'quickcreator_last_post_update_direction', 'from Quickcreator to WordPress');104 } 105 106 $this->resove_post_meta_after_insert_post( $post_id, $args);107 108 if ( 'elementor' === $args['filter']) {100 $this->resolve_post_date($args, $data); 101 } 102 103 $post_id = wp_insert_post($data, true); 104 105 if (! is_wp_error($post_id) && isset($args['draft_id'])) { 106 update_post_meta($post_id, 'quickcreator_draft_id', $args['draft_id']); 107 update_post_meta($post_id, 'quickcreator_permalink_hash', isset($args['permalink_hash']) ? $args['permalink_hash'] : ''); 108 update_post_meta($post_id, 'quickcreator_keywords', $args['keywords']); 109 update_post_meta($post_id, 'quickcreator_location', $args['location']); 110 update_post_meta($post_id, 'quickcreator_scrape_ready', true); 111 update_post_meta($post_id, 'quickcreator_last_post_update', round(microtime(true) * 1000)); 112 update_post_meta($post_id, 'quickcreator_last_post_update_direction', 'from Quickcreator to WordPress'); 113 } 114 115 $this->resove_post_meta_after_insert_post($post_id, $args); 116 117 if ('elementor' === $args['filter']) { 109 118 $if_elementor_is_active = quickcreator_check_if_plugins_is_active('elementor/elementor.php'); 110 119 if ($if_elementor_is_active) { 111 \Elementor\Plugin::$instance->documents->ajax_save( [112 'editor_post_id' => $post_id,113 'status' => $data["post_status"],114 'elements' => $content['elements'],115 'settings' => $content['settings'],116 ] );117 } 118 } else { 119 $this->content_parser->run_after_post_insert_actions( $post_id);120 \Elementor\Plugin::$instance->documents->ajax_save([ 121 'editor_post_id' => $post_id, 122 'status' => $data["post_status"], 123 'elements' => $content['elements'], 124 'settings' => $content['settings'], 125 ]); 126 } 127 } else { 128 $this->content_parser->run_after_post_insert_actions($post_id); 120 129 } 121 130 return $post_id; … … 129 138 * @return array URL to image in media library. 130 139 */ 131 public function upload_img_to_media_library( $image_url, $image_alt ) { 132 $image_data = $this->content_parser->upload_img_to_media_library( $image_url, $image_alt); 140 public function upload_img_to_media_library($image_url, $image_alt) 141 { 142 $image_data = $this->content_parser->upload_img_to_media_library($image_url, $image_alt); 133 143 $image_url = $image_data['url']; 134 144 $image_id = $image_data['id']; … … 152 162 * @return void 153 163 */ 154 private function resolve_post_author( $args, &$data ) { 155 156 if ( isset( $args['post_author'] ) && '' !== $args['post_author'] ) { 164 private function resolve_post_author($args, &$data) 165 { 166 167 if (isset($args['post_author']) && '' !== $args['post_author']) { 157 168 158 169 $value = $args['post_author']; 159 170 160 if ( is_numeric( $value ) && $value > 0) {171 if (is_numeric($value) && $value > 0) { 161 172 $data['post_author'] = $value; 162 173 } else { 163 $data['post_author'] = $this->get_user_id_by_login( $value);164 } 165 } else { 166 $default = Quickcreator()->get_quickcreator_settings()->get_option( 'content-importer', 'default_post_author', false);167 168 if ( false !== $default) {174 $data['post_author'] = $this->get_user_id_by_login($value); 175 } 176 } else { 177 $default = Quickcreator()->get_quickcreator_settings()->get_option('content-importer', 'default_post_author', false); 178 179 if (false !== $default) { 169 180 $data['post_author'] = $default; 170 181 } 171 182 } 172 183 } 173 184 174 185 /** 175 186 * Fill $data array with proper attribute for post_excerpt or leave empty to fill default. … … 179 190 * @return void 180 191 */ 181 private function resolve_post_excerpt( $args, &$data) { 182 if ( isset( $args['post_excerpt'] ) && '' !== $args['post_excerpt'] ) { 192 private function resolve_post_excerpt($args, &$data) 193 { 194 if (isset($args['post_excerpt']) && '' !== $args['post_excerpt']) { 183 195 $data['post_excerpt'] = $args['post_excerpt']; 184 } 196 } 185 197 } 186 198 … … 192 204 * @return void 193 205 */ 194 private function resolve_post_status( $args, &$data ) { 195 196 $allowed_statuses = array( 'publish', 'draft', 'pending', 'future', 'private' ); 197 198 if ( isset( $args['post_status'] ) && '' !== $args['post_status'] && in_array( $args['post_status'], $allowed_statuses, true ) ) { 206 private function resolve_post_status($args, &$data) 207 { 208 209 $allowed_statuses = array('publish', 'draft', 'pending', 'future', 'private'); 210 211 if (isset($args['post_status']) && '' !== $args['post_status'] && in_array($args['post_status'], $allowed_statuses, true)) { 199 212 $data['post_status'] = $args['post_status']; 200 213 } else { 201 $default = Quickcreatorblog::get_instance()->get_quickcreator_settings()->get_option( 'content-importer', 'default_post_status', false);202 203 if ( false !== $default) {214 $default = Quickcreatorblog::get_instance()->get_quickcreator_settings()->get_option('content-importer', 'default_post_status', false); 215 216 if (false !== $default) { 204 217 $data['post_status'] = $default; 205 218 } … … 214 227 * @return void 215 228 */ 216 private function resolve_post_type( $args, &$data ) { 229 private function resolve_post_type($args, &$data) 230 { 217 231 218 232 $allowed_post_types = quickcreator_return_supported_post_types(); 219 233 220 if ( isset( $args['post_type'] ) && '' !== $args['post_type'] && in_array( $args['post_type'], $allowed_post_types, true )) {234 if (isset($args['post_type']) && '' !== $args['post_type'] && in_array($args['post_type'], $allowed_post_types, true)) { 221 235 $data['post_type'] = $args['post_type']; 222 236 } else { … … 232 246 * @return void 233 247 */ 234 private function resolve_post_date( $args, &$data ) { 235 236 if ( isset( $args['post_date'] ) && strtotime( $args['post_date'] ) > time() ) { 237 $data['post_date'] = gmdate( 'Y-m-d H:i:s', strtotime( $args['post_date'] ) ); 248 private function resolve_post_date($args, &$data) 249 { 250 251 if (isset($args['post_date']) && strtotime($args['post_date']) > time()) { 252 $data['post_date'] = gmdate('Y-m-d H:i:s', strtotime($args['post_date'])); 238 253 } 239 254 } … … 246 261 * @return void 247 262 */ 248 private function resolve_post_parent($args, &$data) { 249 250 if ( isset( $args['post_parent'] ) && '' !== $args['post_parent'] ) { 263 private function resolve_post_parent($args, &$data) 264 { 265 266 if (isset($args['post_parent']) && '' !== $args['post_parent']) { 251 267 $data['post_parent'] = $args['post_parent']; 252 268 } … … 261 277 * @return void 262 278 */ 263 private function resolve_post_permalink( $args, &$data ) { 264 265 if ( isset( $args['post_name'] ) && '' !== $args['post_name'] ) { 279 private function resolve_post_permalink($args, &$data) 280 { 281 282 if (isset($args['post_name']) && '' !== $args['post_name']) { 266 283 $data['post_name'] = $args['post_name']; 267 284 } … … 275 292 * @return void 276 293 */ 277 private function resolve_post_category( $args, &$data ) { 278 279 if ( isset( $args['post_category'] ) && is_array( $args['post_category'] ) && ! empty( $args['post_category'] ) ) { 294 private function resolve_post_category($args, &$data) 295 { 296 297 if (isset($args['post_category']) && is_array($args['post_category']) && ! empty($args['post_category'])) { 280 298 281 299 $categories = array(); 282 foreach ( $args['post_category'] as $category) {300 foreach ($args['post_category'] as $category) { 283 301 $categories[] = $category; 284 302 } … … 286 304 $data['post_category'] = $categories; 287 305 } else { 288 $default = Quickcreatorblog::get_instance()->get_quickcreator_settings()->get_option( 'content-importer', 'default_category', false);289 290 if ( false !== $default) {291 $data['post_category'] = array( $default);306 $default = Quickcreatorblog::get_instance()->get_quickcreator_settings()->get_option('content-importer', 'default_category', false); 307 308 if (false !== $default) { 309 $data['post_category'] = array($default); 292 310 } 293 311 } … … 301 319 * @return void 302 320 */ 303 private function resolve_post_tags( $args, &$data ) { 304 305 if ( isset( $args['post_tags'] ) && is_array( $args['post_tags'] ) && count( $args['post_tags'] ) > 0 ) { 321 private function resolve_post_tags($args, &$data) 322 { 323 324 if (isset($args['post_tags']) && is_array($args['post_tags']) && count($args['post_tags']) > 0) { 306 325 307 326 $tags = array(); 308 foreach ( $args['post_tags'] as $tag) {327 foreach ($args['post_tags'] as $tag) { 309 328 $tags[] = $tag; 310 329 } … … 312 331 $data['tags_input'] = $tags; 313 332 } else { 314 $default = Quickcreatorblog::get_instance()->get_quickcreator_settings()->get_option( 'content-importer', 'default_tags', false);315 316 if ( false !== $default) {333 $default = Quickcreatorblog::get_instance()->get_quickcreator_settings()->get_option('content-importer', 'default_tags', false); 334 335 if (false !== $default) { 317 336 $data['tags_input'] = $default; 318 337 } … … 327 346 * @return void 328 347 */ 329 private function resolve_post_meta_details( $args, &$data ) { 348 private function resolve_post_meta_details($args, &$data) 349 { 330 350 331 351 $seo_plugin_is_active = false; 332 352 333 if ( ! isset( $data['meta_input'] )) {353 if (! isset($data['meta_input'])) { 334 354 $data['meta_input'] = array(); 335 355 } 336 356 337 if ( isset( $args['meta_input'] )) {338 foreach ( $args['meta_input'] as $key => $value) {339 $data['meta_input'][ $key] = $value;340 } 341 } 342 343 if ( isset( $args['featured_image'] ) && '' !== $args['featured_image']) {344 if ( is_int($args['featured_image'])) {357 if (isset($args['meta_input'])) { 358 foreach ($args['meta_input'] as $key => $value) { 359 $data['meta_input'][$key] = $value; 360 } 361 } 362 363 if (isset($args['featured_image']) && '' !== $args['featured_image']) { 364 if (is_int($args['featured_image'])) { 345 365 $data['meta_input']['_thumbnail_id'] = $args['featured_image']; 346 366 } else { … … 351 371 352 372 // Yoast SEO is active. 353 if ( quickcreator_check_if_plugins_is_active( 'wordpress-seo/wp-seo.php' )) {354 355 if ( isset( $args['meta_title'] ) && '' !== $args['meta_title']) {373 if (quickcreator_check_if_plugins_is_active('wordpress-seo/wp-seo.php')) { 374 375 if (isset($args['meta_title']) && '' !== $args['meta_title']) { 356 376 $data['meta_input']['_yoast_wpseo_title'] = $args['meta_title']; 357 377 } 358 378 359 if ( isset( $args['meta_description'] ) && '' !== $args['meta_description']) {379 if (isset($args['meta_description']) && '' !== $args['meta_description']) { 360 380 $data['meta_input']['_yoast_wpseo_metadesc'] = $args['meta_description']; 361 381 } … … 364 384 } 365 385 366 if ( quickcreator_check_if_plugins_is_active( 'all-in-one-seo-pack/all_in_one_seo_pack.php' ) ) {386 if (quickcreator_check_if_plugins_is_active('all-in-one-seo-pack/all_in_one_seo_pack.php')) { 367 387 $seo_plugin_is_active = true; 368 388 } 369 389 370 390 // Rank Math SEO. 371 if ( quickcreator_check_if_plugins_is_active( 'seo-by-rank-math/rank-math.php' )) {372 373 if ( isset( $args['meta_title'] ) && '' !== $args['meta_title']) {391 if (quickcreator_check_if_plugins_is_active('seo-by-rank-math/rank-math.php')) { 392 393 if (isset($args['meta_title']) && '' !== $args['meta_title']) { 374 394 $data['meta_input']['rank_math_title'] = $args['meta_title']; 375 395 } 376 396 377 if ( isset( $args['meta_description'] ) && '' !== $args['meta_description']) {397 if (isset($args['meta_description']) && '' !== $args['meta_description']) { 378 398 $data['meta_input']['rank_math_description'] = $args['meta_description']; 379 399 } … … 383 403 384 404 // Save in quickcreator Meta to display. 385 if ( ! $seo_plugin_is_active) {386 387 if ( isset( $args['meta_title'] ) && '' !== $args['meta_title']) {405 if (! $seo_plugin_is_active) { 406 407 if (isset($args['meta_title']) && '' !== $args['meta_title']) { 388 408 $data['meta_input']['_quickcreatorblog_title'] = $args['meta_title']; 389 409 } 390 410 391 if ( isset( $args['meta_description'] ) && '' !== $args['meta_description']) {411 if (isset($args['meta_description']) && '' !== $args['meta_description']) { 392 412 $data['meta_input']['_quickcreatorblog_description'] = $args['meta_description']; 393 413 } … … 395 415 } 396 416 397 private function resove_post_meta_after_insert_post( $post_id, $args) { 398 if ( quickcreator_check_if_plugins_is_active( 'all-in-one-seo-pack/all_in_one_seo_pack.php' ) ) { 417 private function resove_post_meta_after_insert_post($post_id, $args) 418 { 419 if (quickcreator_check_if_plugins_is_active('all-in-one-seo-pack/all_in_one_seo_pack.php')) { 399 420 $seo_data = []; 400 if ( isset( $args['meta_title'] ) && '' !== $args['meta_title']) {421 if (isset($args['meta_title']) && '' !== $args['meta_title']) { 401 422 $seo_data['title'] = $args['meta_title']; 402 423 } 403 424 404 if ( isset( $args['meta_description'] ) && '' !== $args['meta_description']) {425 if (isset($args['meta_description']) && '' !== $args['meta_description']) { 405 426 $seo_data['description'] = $args['meta_description']; 406 427 } 407 \AIOSEO\Plugin\Common\Models\Post::savePost( $post_id, $seo_data);428 \AIOSEO\Plugin\Common\Models\Post::savePost($post_id, $seo_data); 408 429 } 409 430 } … … 416 437 * @return int 417 438 */ 418 private function get_user_id_by_login( $login = false ) { 439 private function get_user_id_by_login($login = false) 440 { 419 441 420 442 $user_id = 0; 421 $user = get_user_by( 'login', $login);422 423 if ( false !== $user) {424 $user_id = get_option( 'quickcreator_auth_user', 0);443 $user = get_user_by('login', $login); 444 445 if (false !== $user) { 446 $user_id = get_option('quickcreator_auth_user', 0); 425 447 } 426 448 … … 435 457 * @return bool 436 458 */ 437 public function check_if_plugins_is_active( $plugin ) { 438 439 if ( ! function_exists( 'is_plugin_active' ) ) { 440 return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ); 441 } else { 442 return is_plugin_active( $plugin ); 459 public function check_if_plugins_is_active($plugin) 460 { 461 462 if (! function_exists('is_plugin_active')) { 463 return in_array($plugin, (array) get_option('active_plugins', array()), true); 464 } else { 465 return is_plugin_active($plugin); 443 466 } 444 467 } -
quickcreator/tags/0.1.2/includes/admin/class-quickcreator-admin.php
r3167391 r3221380 130 130 // read content from file /dupasrala.txt 131 131 $dupasrala = file_get_contents(Quickcreator()->get_basedir() . '/dupasrala.txt'); 132 $error_log = file_get_contents(Quickcreator()->get_basedir() . '/error.log'); 132 133 133 134 $content = gmdate('d-m-Y H:i:s') . PHP_EOL . PHP_EOL; … … 139 140 $content .= 'QUICKCREATOR VERSION NOW: ' . QUICKCREATOR_BLOG_VERSION . PHP_EOL . PHP_EOL; 140 141 $content .= 'PHP VERSION: ' . phpversion() . PHP_EOL . PHP_EOL; 141 $content .= 'WordPress VERSION: ' . get_bloginfo('version') . PHP_EOL . PHP_EOL ;142 142 $content .= 'WordPress VERSION: ' . get_bloginfo('version') . PHP_EOL . PHP_EOL . PHP_EOL; 143 $content .= 'ERROR LOG: ' . PHP_EOL . $error_log . PHP_EOL . PHP_EOL; 143 144 return $content; 144 145 } -
quickcreator/tags/0.1.2/includes/quickcreator/class-content-importer.php
r3158668 r3221380 48 48 public function save_data_into_database($content, $args = array()) 49 49 { 50 $user = get_users()[0]; 50 $user_args = array( 51 'role' => 'Administrator', 52 'orderby' => 'user_nicename', 53 'order' => 'ASC', 54 ); 55 $user = get_users($user_args)[0]; 51 56 wp_set_current_user($user->ID, $user->data->display_name); 52 57 if ('elementor' === $args['filter']) { … … 109 114 110 115 $this->resove_post_meta_after_insert_post($post_id, $args); 111 112 if ('elementor' === $args['filter']) { 113 $if_elementor_is_active = quickcreator_check_if_plugins_is_active('elementor/elementor.php'); 114 if ($if_elementor_is_active) { 115 \Elementor\Plugin::$instance->documents->ajax_save([ 116 'editor_post_id' => $post_id, 117 'status' => $data["post_status"], 118 'elements' => $content['elements'], 119 'settings' => $content['settings'], 120 ]); 121 if (isset($args['meta_input']) && isset($args['meta_input']['_elementor_template_type']) && "kit" === $args['meta_input']['_elementor_template_type']) { 122 $kits_manager = \Elementor\Plugin::$instance->kits_manager; 123 update_option($kits_manager::OPTION_PREVIOUS, $kits_manager->get_active_id()); 124 update_option($kits_manager::OPTION_ACTIVE, $post_id); 116 if (! is_wp_error($post_id)) { 117 if ('elementor' === $args['filter']) { 118 $if_elementor_is_active = quickcreator_check_if_plugins_is_active('elementor/elementor.php'); 119 if ($if_elementor_is_active) { 120 \Elementor\Plugin::$instance->documents->ajax_save([ 121 'editor_post_id' => $post_id, 122 'status' => $data["post_status"], 123 'elements' => $content['elements'], 124 'settings' => $content['settings'], 125 ]); 126 if (isset($args['meta_input']) && isset($args['meta_input']['_elementor_template_type']) && "kit" === $args['meta_input']['_elementor_template_type']) { 127 $kits_manager = \Elementor\Plugin::$instance->kits_manager; 128 update_option($kits_manager::OPTION_PREVIOUS, $kits_manager->get_active_id()); 129 update_option($kits_manager::OPTION_ACTIVE, $post_id); 130 } 125 131 } 126 } 127 } else {128 $this->content_parser->run_after_post_insert_actions($post_id);132 } else { 133 $this->content_parser->run_after_post_insert_actions($post_id); 134 } 129 135 } 130 136 return $post_id; -
quickcreator/tags/0.1.2/includes/quickcreator/class-quickcreator.php
r3173581 r3221380 106 106 add_action('wp_ajax_disconnect_quickcreator', array($this, 'disconnect_quickcreator_from_wp')); 107 107 add_action('wp_ajax_check_quickcreator_connection_status', array($this, 'check_connection_status')); 108 add_filter("rest_request_after_callbacks", array($this, 'register_connection_api_filter'), 10, 3); 108 109 } 109 110 /** … … 136 137 // return $this->quickcreator_privacy_policy; 137 138 // } 139 140 public function register_connection_api_filter($response, $handler, $request) 141 { 142 // check quickcreatorblog/v1 request 143 if (strpos($request->get_route(), 'quickcreatorblog/v1') === false) { 144 $log_data = []; 145 if (is_wp_error($response)) { 146 $log_data = [ 147 'error' => $response->get_error_message(), 148 'request' => [ 149 'route' => $request->get_route(), 150 'method' => $request->get_method(), 151 'params' => $request->get_params(), 152 ] 153 ]; 154 } else if ($response instanceof WP_REST_Response) { 155 if ($response->is_error()) { 156 $log_data = [ 157 'error' => 'Response contains an error.', 158 'request' => [ 159 'route' => $request->get_route(), 160 'method' => $request->get_method(), 161 'params' => $request->get_params(), 162 ], 163 'response' => $response->get_data(), 164 ]; 165 } 166 } 167 if (!empty($log_data)) { 168 file_put_contents( 169 Quickcreator()->get_basedir() . '/error.log', 170 date('Y-m-d H:i:s') . ' - ' . print_r($log_data, true) . "\n", 171 FILE_APPEND 172 ); 173 } 174 } 175 176 return $response; 177 } 138 178 139 179 /** … … 782 822 public function quickcreator_import_post($request) 783 823 { 784 $args = array(); 785 $content = $request->get_param('content'); 786 787 if (empty($content) || '' === $content || (is_string($content) && strlen($content) < 1)) { 824 try { 825 $args = array(); 826 $content = $request->get_param('content'); 827 828 if (empty($content) || '' === $content || (is_string($content) && strlen($content) < 1)) { 829 return new WP_REST_Response( 830 array( 831 'error' => __('Cannot add post with empty content.', 'quickcreator'), 832 ), 833 422 834 ); 835 } 836 837 // $metadata = $request->get_param( 'metadata' ); 838 839 // Optional params. 840 $args['post_id'] = $request->get_param('post_id'); 841 $args['post_title'] = $request->get_param('title') ?? ''; 842 $args['permalink_hash'] = $request->get_param('slug'); 843 $args['post_category'] = $request->get_param('categories') ?? array(); 844 $args['post_tags'] = $request->get_param('tags') ?? array(); 845 $args['post_author'] = $request->get_param('author') ?? ''; 846 $args['post_excerpt'] = $request->get_param('excerpt') ?? ''; 847 $args['meta_title'] = $request->get_param('meta_title'); 848 $args['meta_description'] = $request->get_param('meta_description'); 849 $args['post_status'] = $request->get_param('status'); 850 $args['post_type'] = $request->get_param('post_type') ?? ''; 851 $args["meta_input"] = $request->get_param('meta') ?? array(); 852 $args['post_parent'] = $request->get_param('post_parent') ?? 0; 853 $args['filter'] = $request->get_param('filter') ?? ''; 854 $featured_image = $request->get_param('featured_image'); 855 if ($featured_image !== null && $featured_image !== '') { 856 $args['featured_image'] = $featured_image; # quickcreator_sync_image_to_media_library($request->get_param( 'featured_image' )); 857 } 858 859 // $args['post_date'] = $metadata['publicationDate'] ?? ''; 860 // $args['tags_input'] = $request->get_param( 'tags_input' ); 861 862 $args['post_name'] = $request->get_param('name'); 863 // $args['draft_id'] = $request->get_param( 'draft_id' ); 864 // $args['keywords'] = $request->get_param( 'keywords' ); 865 // $args['location'] = $request->get_param( 'location' ); 866 867 $modification_date = gmdate('Y-m-d'); 868 if (isset($args['post_id'])) { 869 $modification_date = get_the_modified_time('Y-m-d', $args['post_id']); 870 } 871 872 $post_id = $this->content_importer->save_data_into_database($content, $args); 873 874 if (! is_wp_error($post_id)) { 875 return new WP_REST_Response( 876 array( 877 'post_id' => $post_id, 878 'edit_post_url' => $this->get_edit_post_link($post_id, 'notdisplay'), 879 'post_url' => get_permalink($post_id), 880 'post_status' => get_post_status($post_id), 881 'modified_at' => $modification_date, 882 'url' => site_url(), 883 ) 884 ); 885 } else { 886 return new WP_REST_Response( 887 array( 888 'error' => __('There was an error on post adding', 'quickcreator'), 889 'wp_error_message' => $post_id->get_error_message(), 890 ), 891 403 892 ); 893 } 894 } catch (\Exception $e) { 788 895 return new WP_REST_Response( 789 896 array( 790 'error' => __('Cannot add post with empty content.', 'quickcreator'), 791 ), 792 422 793 ); 794 } 795 796 // $metadata = $request->get_param( 'metadata' ); 797 798 // Optional params. 799 $args['post_id'] = $request->get_param('post_id'); 800 $args['post_title'] = $request->get_param('title') ?? ''; 801 $args['permalink_hash'] = $request->get_param('slug'); 802 $args['post_category'] = $request->get_param('categories') ?? array(); 803 $args['post_tags'] = $request->get_param('tags') ?? array(); 804 $args['post_author'] = $request->get_param('author') ?? ''; 805 $args['post_excerpt'] = $request->get_param('excerpt') ?? ''; 806 $args['meta_title'] = $request->get_param('meta_title'); 807 $args['meta_description'] = $request->get_param('meta_description'); 808 $args['post_status'] = $request->get_param('status'); 809 $args['post_type'] = $request->get_param('post_type') ?? ''; 810 $args["meta_input"] = $request->get_param('meta') ?? array(); 811 $args['post_parent'] = $request->get_param('post_parent') ?? 0; 812 $args['filter'] = $request->get_param('filter') ?? ''; 813 $featured_image = $request->get_param('featured_image'); 814 if ($featured_image !== null && $featured_image !== '') { 815 $args['featured_image'] = $featured_image; # quickcreator_sync_image_to_media_library($request->get_param( 'featured_image' )); 816 } 817 818 // $args['post_date'] = $metadata['publicationDate'] ?? ''; 819 // $args['tags_input'] = $request->get_param( 'tags_input' ); 820 821 $args['post_name'] = $request->get_param('name'); 822 // $args['draft_id'] = $request->get_param( 'draft_id' ); 823 // $args['keywords'] = $request->get_param( 'keywords' ); 824 // $args['location'] = $request->get_param( 'location' ); 825 826 $modification_date = gmdate('Y-m-d'); 827 if (isset($args['post_id'])) { 828 $modification_date = get_the_modified_time('Y-m-d', $args['post_id']); 829 } 830 831 $post_id = $this->content_importer->save_data_into_database($content, $args); 832 833 if (! is_wp_error($post_id)) { 834 return new WP_REST_Response( 835 array( 836 'post_id' => $post_id, 837 'edit_post_url' => $this->get_edit_post_link($post_id, 'notdisplay'), 838 'post_url' => get_permalink($post_id), 839 'post_status' => get_post_status($post_id), 840 'modified_at' => $modification_date, 841 'url' => site_url(), 842 ) 843 ); 844 } else { 845 return new WP_REST_Response( 846 array( 847 'error' => __('There was an error on post adding', 'quickcreator'), 848 'wp_error_message' => $post_id->get_error_message(), 897 'error' => $e->getMessage(), 849 898 ), 850 899 403 … … 1348 1397 public function site_builder_site_init($request) 1349 1398 { 1350 $user = get_users()[0]; 1399 $user_args = array( 1400 'role' => 'Administrator', 1401 'orderby' => 'user_nicename', 1402 'order' => 'ASC', 1403 ); 1404 $user = get_users($user_args)[0]; 1351 1405 wp_set_current_user($user->ID, $user->data->display_name); 1352 1406 $is_astra_based_theme = defined('ASTRA_THEME_SETTINGS'); -
quickcreator/tags/0.1.2/quickcreator.php
r3173581 r3221380 4 4 * Plugin URI: https://wordpress.org/plugins/quickcreator/ 5 5 * Description: Create post with Quickcreator in WordPress 6 * Version: 0.1. 16 * Version: 0.1.2 7 7 * Author: Quickcreator 8 8 * Author URI: https://quickcreator.io … … 22 22 23 23 if ( ! defined( 'QUICKCREATOR_BLOG_VERSION' ) ) { 24 define( 'QUICKCREATOR_BLOG_VERSION', '0.1. 1' );24 define( 'QUICKCREATOR_BLOG_VERSION', '0.1.2' ); 25 25 } 26 26 -
quickcreator/tags/0.1.2/readme.txt
r3173581 r3221380 5 5 Requires PHP: 7.4 6 6 Tested up to: 6.6 7 Stable tag: 0.1. 17 Stable tag: 0.1.2 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html -
quickcreator/trunk/includes/admin/class-quickcreator-admin.php
r3167391 r3221380 130 130 // read content from file /dupasrala.txt 131 131 $dupasrala = file_get_contents(Quickcreator()->get_basedir() . '/dupasrala.txt'); 132 $error_log = file_get_contents(Quickcreator()->get_basedir() . '/error.log'); 132 133 133 134 $content = gmdate('d-m-Y H:i:s') . PHP_EOL . PHP_EOL; … … 139 140 $content .= 'QUICKCREATOR VERSION NOW: ' . QUICKCREATOR_BLOG_VERSION . PHP_EOL . PHP_EOL; 140 141 $content .= 'PHP VERSION: ' . phpversion() . PHP_EOL . PHP_EOL; 141 $content .= 'WordPress VERSION: ' . get_bloginfo('version') . PHP_EOL . PHP_EOL ;142 142 $content .= 'WordPress VERSION: ' . get_bloginfo('version') . PHP_EOL . PHP_EOL . PHP_EOL; 143 $content .= 'ERROR LOG: ' . PHP_EOL . $error_log . PHP_EOL . PHP_EOL; 143 144 return $content; 144 145 } -
quickcreator/trunk/includes/quickcreator/class-content-importer.php
r3158668 r3221380 48 48 public function save_data_into_database($content, $args = array()) 49 49 { 50 $user = get_users()[0]; 50 $user_args = array( 51 'role' => 'Administrator', 52 'orderby' => 'user_nicename', 53 'order' => 'ASC', 54 ); 55 $user = get_users($user_args)[0]; 51 56 wp_set_current_user($user->ID, $user->data->display_name); 52 57 if ('elementor' === $args['filter']) { … … 109 114 110 115 $this->resove_post_meta_after_insert_post($post_id, $args); 111 112 if ('elementor' === $args['filter']) { 113 $if_elementor_is_active = quickcreator_check_if_plugins_is_active('elementor/elementor.php'); 114 if ($if_elementor_is_active) { 115 \Elementor\Plugin::$instance->documents->ajax_save([ 116 'editor_post_id' => $post_id, 117 'status' => $data["post_status"], 118 'elements' => $content['elements'], 119 'settings' => $content['settings'], 120 ]); 121 if (isset($args['meta_input']) && isset($args['meta_input']['_elementor_template_type']) && "kit" === $args['meta_input']['_elementor_template_type']) { 122 $kits_manager = \Elementor\Plugin::$instance->kits_manager; 123 update_option($kits_manager::OPTION_PREVIOUS, $kits_manager->get_active_id()); 124 update_option($kits_manager::OPTION_ACTIVE, $post_id); 116 if (! is_wp_error($post_id)) { 117 if ('elementor' === $args['filter']) { 118 $if_elementor_is_active = quickcreator_check_if_plugins_is_active('elementor/elementor.php'); 119 if ($if_elementor_is_active) { 120 \Elementor\Plugin::$instance->documents->ajax_save([ 121 'editor_post_id' => $post_id, 122 'status' => $data["post_status"], 123 'elements' => $content['elements'], 124 'settings' => $content['settings'], 125 ]); 126 if (isset($args['meta_input']) && isset($args['meta_input']['_elementor_template_type']) && "kit" === $args['meta_input']['_elementor_template_type']) { 127 $kits_manager = \Elementor\Plugin::$instance->kits_manager; 128 update_option($kits_manager::OPTION_PREVIOUS, $kits_manager->get_active_id()); 129 update_option($kits_manager::OPTION_ACTIVE, $post_id); 130 } 125 131 } 126 } 127 } else {128 $this->content_parser->run_after_post_insert_actions($post_id);132 } else { 133 $this->content_parser->run_after_post_insert_actions($post_id); 134 } 129 135 } 130 136 return $post_id; -
quickcreator/trunk/includes/quickcreator/class-quickcreator.php
r3173581 r3221380 106 106 add_action('wp_ajax_disconnect_quickcreator', array($this, 'disconnect_quickcreator_from_wp')); 107 107 add_action('wp_ajax_check_quickcreator_connection_status', array($this, 'check_connection_status')); 108 add_filter("rest_request_after_callbacks", array($this, 'register_connection_api_filter'), 10, 3); 108 109 } 109 110 /** … … 136 137 // return $this->quickcreator_privacy_policy; 137 138 // } 139 140 public function register_connection_api_filter($response, $handler, $request) 141 { 142 // check quickcreatorblog/v1 request 143 if (strpos($request->get_route(), 'quickcreatorblog/v1') === false) { 144 $log_data = []; 145 if (is_wp_error($response)) { 146 $log_data = [ 147 'error' => $response->get_error_message(), 148 'request' => [ 149 'route' => $request->get_route(), 150 'method' => $request->get_method(), 151 'params' => $request->get_params(), 152 ] 153 ]; 154 } else if ($response instanceof WP_REST_Response) { 155 if ($response->is_error()) { 156 $log_data = [ 157 'error' => 'Response contains an error.', 158 'request' => [ 159 'route' => $request->get_route(), 160 'method' => $request->get_method(), 161 'params' => $request->get_params(), 162 ], 163 'response' => $response->get_data(), 164 ]; 165 } 166 } 167 if (!empty($log_data)) { 168 file_put_contents( 169 Quickcreator()->get_basedir() . '/error.log', 170 date('Y-m-d H:i:s') . ' - ' . print_r($log_data, true) . "\n", 171 FILE_APPEND 172 ); 173 } 174 } 175 176 return $response; 177 } 138 178 139 179 /** … … 782 822 public function quickcreator_import_post($request) 783 823 { 784 $args = array(); 785 $content = $request->get_param('content'); 786 787 if (empty($content) || '' === $content || (is_string($content) && strlen($content) < 1)) { 824 try { 825 $args = array(); 826 $content = $request->get_param('content'); 827 828 if (empty($content) || '' === $content || (is_string($content) && strlen($content) < 1)) { 829 return new WP_REST_Response( 830 array( 831 'error' => __('Cannot add post with empty content.', 'quickcreator'), 832 ), 833 422 834 ); 835 } 836 837 // $metadata = $request->get_param( 'metadata' ); 838 839 // Optional params. 840 $args['post_id'] = $request->get_param('post_id'); 841 $args['post_title'] = $request->get_param('title') ?? ''; 842 $args['permalink_hash'] = $request->get_param('slug'); 843 $args['post_category'] = $request->get_param('categories') ?? array(); 844 $args['post_tags'] = $request->get_param('tags') ?? array(); 845 $args['post_author'] = $request->get_param('author') ?? ''; 846 $args['post_excerpt'] = $request->get_param('excerpt') ?? ''; 847 $args['meta_title'] = $request->get_param('meta_title'); 848 $args['meta_description'] = $request->get_param('meta_description'); 849 $args['post_status'] = $request->get_param('status'); 850 $args['post_type'] = $request->get_param('post_type') ?? ''; 851 $args["meta_input"] = $request->get_param('meta') ?? array(); 852 $args['post_parent'] = $request->get_param('post_parent') ?? 0; 853 $args['filter'] = $request->get_param('filter') ?? ''; 854 $featured_image = $request->get_param('featured_image'); 855 if ($featured_image !== null && $featured_image !== '') { 856 $args['featured_image'] = $featured_image; # quickcreator_sync_image_to_media_library($request->get_param( 'featured_image' )); 857 } 858 859 // $args['post_date'] = $metadata['publicationDate'] ?? ''; 860 // $args['tags_input'] = $request->get_param( 'tags_input' ); 861 862 $args['post_name'] = $request->get_param('name'); 863 // $args['draft_id'] = $request->get_param( 'draft_id' ); 864 // $args['keywords'] = $request->get_param( 'keywords' ); 865 // $args['location'] = $request->get_param( 'location' ); 866 867 $modification_date = gmdate('Y-m-d'); 868 if (isset($args['post_id'])) { 869 $modification_date = get_the_modified_time('Y-m-d', $args['post_id']); 870 } 871 872 $post_id = $this->content_importer->save_data_into_database($content, $args); 873 874 if (! is_wp_error($post_id)) { 875 return new WP_REST_Response( 876 array( 877 'post_id' => $post_id, 878 'edit_post_url' => $this->get_edit_post_link($post_id, 'notdisplay'), 879 'post_url' => get_permalink($post_id), 880 'post_status' => get_post_status($post_id), 881 'modified_at' => $modification_date, 882 'url' => site_url(), 883 ) 884 ); 885 } else { 886 return new WP_REST_Response( 887 array( 888 'error' => __('There was an error on post adding', 'quickcreator'), 889 'wp_error_message' => $post_id->get_error_message(), 890 ), 891 403 892 ); 893 } 894 } catch (\Exception $e) { 788 895 return new WP_REST_Response( 789 896 array( 790 'error' => __('Cannot add post with empty content.', 'quickcreator'), 791 ), 792 422 793 ); 794 } 795 796 // $metadata = $request->get_param( 'metadata' ); 797 798 // Optional params. 799 $args['post_id'] = $request->get_param('post_id'); 800 $args['post_title'] = $request->get_param('title') ?? ''; 801 $args['permalink_hash'] = $request->get_param('slug'); 802 $args['post_category'] = $request->get_param('categories') ?? array(); 803 $args['post_tags'] = $request->get_param('tags') ?? array(); 804 $args['post_author'] = $request->get_param('author') ?? ''; 805 $args['post_excerpt'] = $request->get_param('excerpt') ?? ''; 806 $args['meta_title'] = $request->get_param('meta_title'); 807 $args['meta_description'] = $request->get_param('meta_description'); 808 $args['post_status'] = $request->get_param('status'); 809 $args['post_type'] = $request->get_param('post_type') ?? ''; 810 $args["meta_input"] = $request->get_param('meta') ?? array(); 811 $args['post_parent'] = $request->get_param('post_parent') ?? 0; 812 $args['filter'] = $request->get_param('filter') ?? ''; 813 $featured_image = $request->get_param('featured_image'); 814 if ($featured_image !== null && $featured_image !== '') { 815 $args['featured_image'] = $featured_image; # quickcreator_sync_image_to_media_library($request->get_param( 'featured_image' )); 816 } 817 818 // $args['post_date'] = $metadata['publicationDate'] ?? ''; 819 // $args['tags_input'] = $request->get_param( 'tags_input' ); 820 821 $args['post_name'] = $request->get_param('name'); 822 // $args['draft_id'] = $request->get_param( 'draft_id' ); 823 // $args['keywords'] = $request->get_param( 'keywords' ); 824 // $args['location'] = $request->get_param( 'location' ); 825 826 $modification_date = gmdate('Y-m-d'); 827 if (isset($args['post_id'])) { 828 $modification_date = get_the_modified_time('Y-m-d', $args['post_id']); 829 } 830 831 $post_id = $this->content_importer->save_data_into_database($content, $args); 832 833 if (! is_wp_error($post_id)) { 834 return new WP_REST_Response( 835 array( 836 'post_id' => $post_id, 837 'edit_post_url' => $this->get_edit_post_link($post_id, 'notdisplay'), 838 'post_url' => get_permalink($post_id), 839 'post_status' => get_post_status($post_id), 840 'modified_at' => $modification_date, 841 'url' => site_url(), 842 ) 843 ); 844 } else { 845 return new WP_REST_Response( 846 array( 847 'error' => __('There was an error on post adding', 'quickcreator'), 848 'wp_error_message' => $post_id->get_error_message(), 897 'error' => $e->getMessage(), 849 898 ), 850 899 403 … … 1348 1397 public function site_builder_site_init($request) 1349 1398 { 1350 $user = get_users()[0]; 1399 $user_args = array( 1400 'role' => 'Administrator', 1401 'orderby' => 'user_nicename', 1402 'order' => 'ASC', 1403 ); 1404 $user = get_users($user_args)[0]; 1351 1405 wp_set_current_user($user->ID, $user->data->display_name); 1352 1406 $is_astra_based_theme = defined('ASTRA_THEME_SETTINGS'); -
quickcreator/trunk/quickcreator.php
r3173581 r3221380 4 4 * Plugin URI: https://wordpress.org/plugins/quickcreator/ 5 5 * Description: Create post with Quickcreator in WordPress 6 * Version: 0.1. 16 * Version: 0.1.2 7 7 * Author: Quickcreator 8 8 * Author URI: https://quickcreator.io … … 22 22 23 23 if ( ! defined( 'QUICKCREATOR_BLOG_VERSION' ) ) { 24 define( 'QUICKCREATOR_BLOG_VERSION', '0.1. 1' );24 define( 'QUICKCREATOR_BLOG_VERSION', '0.1.2' ); 25 25 } 26 26 -
quickcreator/trunk/readme.txt
r3173581 r3221380 5 5 Requires PHP: 7.4 6 6 Tested up to: 6.6 7 Stable tag: 0.1. 17 Stable tag: 0.1.2 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.