Changeset 2851725
- Timestamp:
- 01/20/2023 08:18:57 AM (3 years ago)
- Location:
- seo-quick-images/trunk
- Files:
-
- 6 edited
-
admin/admin-general-setting.php (modified) (8 diffs)
-
assets/css/seo_images_style.css (modified) (4 diffs)
-
assets/js/seo_images_ajax_script.js (modified) (5 diffs)
-
loader.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
seo_images.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
seo-quick-images/trunk/admin/admin-general-setting.php
r2819949 r2851725 9 9 add_action("wp_ajax_addPostTypeFlag", array($this, "SEO_IMAGES_addPostTypeFlag")); 10 10 add_action("wp_ajax_nopriv_addPostTypeFlag", array($this, "SEO_IMAGES_addPostTypeFlag")); 11 add_action("wp_ajax_call_imageApi", array($this, "SEO_IMAGES_call_image_api")); 11 12 add_action("wp_ajax_call_imageApi", array($this, "SEO_IMAGES_call_image_api")); 12 13 add_action("wp_ajax_nopriv_call_imageApi", array($this, "SEO_IMAGES_call_image_api")); 14 15 add_action("wp_ajax_set_featured_image", array($this, "SEO_IMAGES_set_featured_image")); 16 add_action("wp_ajax_nopriv_set_featured_image", array($this, "SEO_IMAGES_set_featured_image")); 17 13 18 add_action("wp_ajax_insert_selected_imageApi", array( $this, "insert_selected_imageApi" ) ); 14 19 add_action("wp_ajax_seo_images_savePost", array( $this, "seo_images_savePost" ) ); … … 361 366 } 362 367 368 public function SEO_IMAGES_set_featured_image(){ 369 if( !empty($_POST)){ 370 header('Content-Type: application/json'); 371 $post_id = sanitize_text_field( $_POST['p_id'] ); 372 $featured_image = sanitize_text_field( $_POST['featured_image']); 373 $article_title = sanitize_text_field( $_POST['article_title'] ); 374 $name = $article_title; 375 $uniqu_prefix = AdminGeneralSettingSEO_IMAGES::preNameSetter(8); 376 $file_name = $uniqu_prefix.'_'.$name; 377 $size_resolution = 'full'; 378 $featured = 'yes'; 379 380 if(strpos($featured_image, '.jpg') !== false || 381 strpos($featured_image, '.jpeg') !== false || 382 strpos($featured_image, '.gif') !== false || 383 strpos($featured_image, '.png') !== false || 384 strpos($featured_image, '.bmp') !== false 385 ) { 386 // then only upload & set featured image 387 $flag = AdminGeneralSettingSEO_IMAGES::uploadImageToWP($featured_image, $post_id, $file_name, $size_resolution, $featured); 388 } 389 390 if($flag != 'no_image' && !empty($flag)) { 391 // means image is uploaded 392 $featured_image_response['image'] = $flag; 393 echo json_encode( array('status' => 0, 'message' => 'ok' )); 394 } else if($flag == 'no_image') { 395 echo json_encode( array('status' => -1, 'message' => 'no_image' )); 396 } else { 397 echo json_encode( array('status' => -2, 'message' => 'something wrong' )); 398 } 399 } else { 400 $msg = 0; 401 echo json_encode($msg); 402 } 403 exit(); 404 } 405 363 406 public function SEO_IMAGES_call_image_api(){ 364 407 … … 406 449 407 450 if( is_wp_error( $data ) ) { 408 //file_put_contents( $_SERVER['DOCUMENT_ROOT'] . "/seo_images.log", date( 'Y-m-d H:i:s' ) . ' --> ' . print_r( $data, true ), FILE_APPEND | LOCK_EX );451 file_put_contents( $_SERVER['DOCUMENT_ROOT'] . "/seo_images.log", date( 'Y-m-d H:i:s' ) . ' --> ' . print_r( $data, true ), FILE_APPEND | LOCK_EX ); 409 452 exit; 410 453 } … … 425 468 426 469 $g_array = json_decode($g_data, true); 470 471 //file_put_contents( $_SERVER['DOCUMENT_ROOT'] . "/seo_images.log", date( 'Y-m-d H:i:s' ) . ' --> ' . print_r( $g_array, true ), FILE_APPEND | LOCK_EX ); 427 472 428 473 $name = $article_title; … … 444 489 ) { 445 490 // then only upload & set featured image 446 $flag = AdminGeneralSettingSEO_IMAGES::uploadImageToWP($file_path[$a], $post_id, $file_name, $size_resolution, $featured); 491 // Featured image is in custom ajax 492 //$flag = AdminGeneralSettingSEO_IMAGES::uploadImageToWP($file_path[$a], $post_id, $file_name, $size_resolution, $featured); 447 493 } 448 494 … … 471 517 472 518 $args = array( 473 'timeout' => 120,519 'timeout' => 240, 474 520 'sslverify' => false 475 521 ); … … 478 524 479 525 if( is_wp_error( $data ) ) { 480 //file_put_contents( $_SERVER['DOCUMENT_ROOT'] . "/seo_images.log", date( 'Y-m-d H:i:s' ) . ' --> ' . print_r( $data, true ) . "\n" . $remote_get . "\n", FILE_APPEND | LOCK_EX );526 file_put_contents( $_SERVER['DOCUMENT_ROOT'] . "/seo_images.log", date( 'Y-m-d H:i:s' ) . ' --> ' . print_r( $data, true ) . "\n" . $remote_get . "\n", FILE_APPEND | LOCK_EX ); 481 527 exit; 482 528 } … … 493 539 "images_ar" => $rowData->images_ar, 494 540 "heading_val" => $rowData->heading_val, 541 "g_data_query" => $g_array['query'], 542 "g_data_images" => $g_array['images'], 543 "g_data" => $g_array 495 544 ); 496 545 -
seo-quick-images/trunk/assets/css/seo_images_style.css
r2769630 r2851725 82 82 } 83 83 84 .seo_images_selection_group {84 .seo_images_selection_group, .seo_images_featured_selection_group { 85 85 float: left; 86 86 width: 100%; … … 88 88 } 89 89 90 .seo_images_selection_container {90 .seo_images_selection_container, .seo_images_featured_selection_container { 91 91 float: left; 92 92 width: 30%; … … 101 101 } 102 102 103 img.seo_images_selection_image {103 img.seo_images_selection_image, img.seo_images_featured_selection_image { 104 104 max-height: 50px; 105 105 cursor: pointer; … … 107 107 } 108 108 109 .seo_images_selection_container.selected {109 .seo_images_selection_container.selected, .seo_images_featured_selection_container.selected { 110 110 border: 1px solid green; 111 111 } 112 112 113 .seo_images_selection_selected {113 .seo_images_selection_selected, .seo_images_featured_selection_selected { 114 114 display: none; 115 115 position: absolute; -
seo-quick-images/trunk/assets/js/seo_images_ajax_script.js
r2769630 r2851725 608 608 } 609 609 610 let featured_html = ``; 611 612 /** 613 * Featured image 614 */ 615 const images = data.g_data_images; 616 featured_html += `<div class="seo_images_featured_selection_group"><h3>Featured image</h3>`; 617 featured_html += `<div class="seo_images_featured_selection_main">`; 618 for( let i = 0; i < images.length; i++ ) { 619 const src = images[ i ].replaceAll( "'", "\\'" ); 620 featured_html += `<div class="seo_images_featured_selection_container" data-image="`+ images[ i ] +`" style="background-image: url(`+ src +`)"> 621 <div class="seo_images_featured_selection_selected"> 622 <span class="dashicons dashicons-yes"></span> 623 </div> 624 </div>`; 625 } 626 featured_html += `</div>`; 627 featured_html += `</div>`; 628 629 /** 630 * Body images 631 */ 610 632 let html = ``; 611 633 for( let i = 0; i < data.heading_val.length; i++ ) { … … 659 681 <!-- <button type="button" class="button button-primary" onclick="_seoImagesReset();">Reset</button> --> 660 682 </div>`; 661 jQuery('#seo_images_selection_buttons').html( html ); 662 663 683 jQuery('#seo_images_selection_buttons').html( featured_html + html ); 664 684 } 665 685 }); … … 674 694 }); 675 695 696 jQuery('body').on('click', '.seo_images_featured_selection_container', function(){ 697 jQuery( this ).parent().find('.seo_images_featured_selection_container').removeClass( 'selected' ); 698 jQuery( this ).parent().find('.seo_images_featured_selection_container').find( '.seo_images_featured_selection_selected' ).hide(); 699 jQuery( this ).addClass( 'selected' ); 700 jQuery( this ).find( '.seo_images_featured_selection_selected' ).show(); 701 }); 702 676 703 jQuery('body').on('click', '#insert_selected', function(){ 677 704 let array = []; 705 706 jQuery('.seo_images_featured_selection_group').each(function(){ 707 const featured_image = jQuery(this).find('.selected').data('image'); 708 let article_title = $("#article_title").val(); 709 let p_id = $("#p_id").val(); 710 jQuery.ajax({ 711 type: "POST", 712 url: ajax_object.ajaxurl, 713 //data: formData, 714 data: { 715 action: "set_featured_image", 716 p_id: p_id, 717 featured_image: featured_image, 718 article_title: article_title, 719 }, 720 dataType: 'json', 721 }).fail(function(a, b, c){ 722 console.log('Ajax request fails'); 723 console.log( a ); 724 console.log( b ); 725 console.log( c ); 726 }).done(function( data ){ 727 console.log( data ); 728 }); 729 730 }); 731 678 732 jQuery('.seo_images_selection_group').each(function(){ 679 733 let element = []; … … 762 816 } 763 817 818 if( h_id == '' ) { 819 // Sono nella featured 820 console.log( 'sono nella featured', value); 821 return; 822 } 823 764 824 // if error is true 765 825 if( error == "true" ) { … … 781 841 const rootClientId = jQuery('.block-editor-writing-flow').find("#"+h_id).data('block'); 782 842 const blocks = wp.data.select('core/editor').getBlocks(); 783 let i = 0; 784 for( i = 0; i < blocks.length; i++ ) { 843 for( let i = 1; i < blocks.length; i++ ) { 785 844 if( blocks[i].clientId == rootClientId ) { 786 845 break; -
seo-quick-images/trunk/loader.php
r2769630 r2851725 15 15 function __construct() { 16 16 require_once SEO_IMAGES_PATH_ABS . 'admin/admin-general-setting.php'; 17 add_action('admin_print_styles ', array($this, 'seo_images_stylesheet'));18 add_action('admin_print_styles ', array($this, 'addAjaxToPluginseo_images'));17 add_action('admin_print_styles-post.php', array($this, 'seo_images_stylesheet')); 18 add_action('admin_print_styles-post.php', array($this, 'addAjaxToPluginseo_images')); 19 19 } 20 20 -
seo-quick-images/trunk/readme.txt
r2819949 r2851725 2 2 Contributors: WP Seo Plugins 3 3 Donate link: 4 Tags: seo, images , quick images insertion, automatic images, seo images, artificial intelligence, automatic images4 Tags: seo, images 5 5 Requires at least: 4.7 6 Tested up to: 6. 1.17 Stable tag: 1.3 6 Tested up to: 6.0 7 Stable tag: 1.3.1 8 8 Requires PHP: 7.1 9 9 License: GPLv2 or later … … 27 27 28 28 == Upgrade Notice == 29 30 = 1.3.1 = better overall stability and many usability issues fixed 29 31 30 32 = 1.2.1 = -
seo-quick-images/trunk/seo_images.php
r2819949 r2851725 1 1 <?php 2 define( 'SEO_IMAGES_VERSION', '1.2. 2' );2 define( 'SEO_IMAGES_VERSION', '1.2.3' ); 3 3 /** 4 4 * Plugin Name: Seo Quick Images … … 6 6 * Author: WP SEO Plugins 7 7 * Description: SEO Images is a powerful plugin that helps you add images in your wordpress posts, based on titles. Enhance your content with a lot of images! 8 * Version: 1.2. 28 * Version: 1.2.3 9 9 */ 10 10
Note: See TracChangeset
for help on using the changeset viewer.