Plugin Directory

Changeset 2851725


Ignore:
Timestamp:
01/20/2023 08:18:57 AM (3 years ago)
Author:
seomantis
Message:

many usability and stability issues fixed, new features added

Location:
seo-quick-images/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • seo-quick-images/trunk/admin/admin-general-setting.php

    r2819949 r2851725  
    99        add_action("wp_ajax_addPostTypeFlag", array($this, "SEO_IMAGES_addPostTypeFlag"));
    1010        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"));
    1213        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
    1318        add_action("wp_ajax_insert_selected_imageApi", array( $this, "insert_selected_imageApi" ) );
    1419        add_action("wp_ajax_seo_images_savePost", array( $this, "seo_images_savePost" ) );
     
    361366    }
    362367
     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
    363406    public function SEO_IMAGES_call_image_api(){
    364407
     
    406449
    407450            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 );
    409452                exit;
    410453            }
     
    425468
    426469                $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 );
    427472
    428473                $name = $article_title;
     
    444489                        ) {
    445490                            // 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);
    447493                        }
    448494                       
     
    471517
    472518            $args = array(
    473                 'timeout'     => 120,
     519                'timeout'     => 240,
    474520                'sslverify' => false
    475521            );
     
    478524
    479525            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 );
    481527                exit;
    482528            }
     
    493539                "images_ar" => $rowData->images_ar,
    494540                "heading_val" => $rowData->heading_val,
     541                "g_data_query" => $g_array['query'],
     542                "g_data_images" => $g_array['images'],
     543                "g_data" => $g_array
    495544            );
    496545
  • seo-quick-images/trunk/assets/css/seo_images_style.css

    r2769630 r2851725  
    8282}
    8383
    84 .seo_images_selection_group {
     84.seo_images_selection_group, .seo_images_featured_selection_group {
    8585    float: left;
    8686    width: 100%;
     
    8888}
    8989
    90 .seo_images_selection_container {
     90.seo_images_selection_container, .seo_images_featured_selection_container {
    9191    float: left;
    9292    width: 30%;
     
    101101}
    102102
    103 img.seo_images_selection_image {
     103img.seo_images_selection_image, img.seo_images_featured_selection_image {
    104104    max-height: 50px;
    105105    cursor: pointer;
     
    107107}
    108108
    109 .seo_images_selection_container.selected {
     109.seo_images_selection_container.selected, .seo_images_featured_selection_container.selected {
    110110    border: 1px solid green;
    111111}
    112112
    113 .seo_images_selection_selected {
     113.seo_images_selection_selected, .seo_images_featured_selection_selected {
    114114    display: none;
    115115    position: absolute;
  • seo-quick-images/trunk/assets/js/seo_images_ajax_script.js

    r2769630 r2851725  
    608608          }
    609609
     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           */
    610632          let html = ``;
    611633          for( let i = 0; i < data.heading_val.length; i++ ) {
     
    659681                            <!-- <button type="button" class="button button-primary" onclick="_seoImagesReset();">Reset</button> -->
    660682                      </div>`;
    661           jQuery('#seo_images_selection_buttons').html( html );
    662 
    663 
     683          jQuery('#seo_images_selection_buttons').html( featured_html + html );
    664684        }
    665685      });
     
    674694  });
    675695
     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
    676703  jQuery('body').on('click', '#insert_selected', function(){
    677704    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
    678732    jQuery('.seo_images_selection_group').each(function(){
    679733      let element = [];
     
    762816        }
    763817
     818        if( h_id == '' ) {
     819          // Sono nella featured
     820          console.log( 'sono nella featured', value);
     821          return;
     822        }
     823
    764824        // if error is true
    765825        if( error == "true" ) {
     
    781841              const rootClientId = jQuery('.block-editor-writing-flow').find("#"+h_id).data('block');
    782842              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++ ) {
    785844                if( blocks[i].clientId == rootClientId ) {
    786845                  break;
  • seo-quick-images/trunk/loader.php

    r2769630 r2851725  
    1515    function __construct() {
    1616        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'));
    1919    }
    2020
  • seo-quick-images/trunk/readme.txt

    r2819949 r2851725  
    22Contributors: WP Seo Plugins
    33Donate link:
    4 Tags: seo, images, quick images insertion, automatic images, seo images, artificial intelligence, automatic images
     4Tags: seo, images
    55Requires at least: 4.7
    6 Tested up to: 6.1.1
    7 Stable tag: 1.3
     6Tested up to: 6.0
     7Stable tag: 1.3.1
    88Requires PHP: 7.1
    99License: GPLv2 or later
     
    2727
    2828== Upgrade Notice ==
     29
     30= 1.3.1 = better overall stability and many usability issues fixed
    2931
    3032= 1.2.1 =
  • seo-quick-images/trunk/seo_images.php

    r2819949 r2851725  
    11<?php
    2 define( 'SEO_IMAGES_VERSION', '1.2.2' );
     2define( 'SEO_IMAGES_VERSION', '1.2.3' );
    33/**
    44 * Plugin Name: Seo Quick Images
     
    66 * Author: WP SEO Plugins
    77 * 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.2
     8 * Version: 1.2.3
    99 */
    1010
Note: See TracChangeset for help on using the changeset viewer.