Plugin Directory

Changeset 2548884


Ignore:
Timestamp:
06/16/2021 11:48:48 AM (5 years ago)
Author:
resoc
Message:

Version 1.0.2

Location:
resoc/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • resoc/trunk/README.txt

    r2544884 r2548884  
    55Requires at least: 5.0
    66Tested up to: 5.7.2
    7 Stable tag: 1.0.1
     7Stable tag: 1.0.2
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8181== Changelog ==
    8282
     83= 1.0.2 =
     84* Compatibility with Yoast SEO and All in One SEO
     85* Detect conflicts with other plugins
     86* Generate image on auto-save
     87* Generate image only on change
     88
    8389= 1.0.1 =
    8490* Minor fix in post save
  • resoc/trunk/admin/class-resoc-admin.php

    r2544884 r2548884  
    6666    }
    6767
    68     if ( wp_is_post_autosave( $post_ID ) ) {
    69       Resoc_Utils::log( "Post " . $post_ID . " is autosaving, skip" );
    70       return;
    71     }
    72 
    7368    $feature_image_url = Resoc_Utils::get_post_featured_image_url( $post_ID );
    7469    if ( !$feature_image_url ) {
     
    9691    );
    9792
     93    $current_request_hash = Resoc_Utils::hash_request( $request );
     94    $previous_request_hash = get_post_meta( $post_ID, Resoc::POST_META_LATEST_REQUEST_HASH, true );
     95    if ( $previous_request_hash && $previous_request_hash == $current_request_hash ) {
     96      Resoc_Utils::log( "No change since the last time the image was generated, do nothing" );
     97      return;
     98    }
     99
    98100    $social_image = Resoc_Utils::create_social_image( $request );
    99101    if ( !$social_image ) {
     
    112114
    113115    update_post_meta( $post_ID, Resoc::POST_META_OG_IMAGE_ID, $social_image_id );
     116
     117    update_post_meta( $post_ID, Resoc::POST_META_LATEST_REQUEST_HASH, $current_request_hash );
    114118
    115119    Resoc_Utils::log( "OpenGraph image " . $social_image_id . " attached to post " . $post_ID );
  • resoc/trunk/admin/class-resoc-settings.php

    r2544870 r2548884  
    8787    }
    8888
     89    if ( Resoc_Compatibility::conflicting_plugin() ) {
     90      include_once( plugin_dir_path(__FILE__) . 'partials' . DIRECTORY_SEPARATOR . 'appearance-conflict-fallback.php' );
     91      return;
     92    }
     93
    8994    include_once( plugin_dir_path(__FILE__) . 'partials' . DIRECTORY_SEPARATOR . 'appearance.php' );
    9095  }
     
    167172        </p>
    168173
    169         <div class="resoc-before-after">
    170           <div class="before">
    171             <h3>Before</h3>
    172             <p>No branding, generic stock image</p>
    173             <img src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . 'img/before.jpg' ) ?>" />
    174           </div>
    175           <div class="before-after-link">
    176             &rarr;
    177           </div>
    178           <div class="after">
    179             <h3>After</h3>
    180             <p>Branded, eye catching</p>
    181             <img src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . 'img/after.jpg' ) ?>" />
    182           </div>
    183         </div>
     174        <?php
     175          include_once( plugin_dir_path(__FILE__) . 'partials' . DIRECTORY_SEPARATOR . 'before-after.php' );
     176        ?>
    184177
    185178        <p>
  • resoc/trunk/admin/css/resoc-admin.css

    r2544870 r2548884  
    5151  display: none;
    5252}
     53
     54.resoc-title-error {
     55  color: red;
     56}
     57
     58.resoc-narrow-section {
     59  max-width: 600px;
     60}
  • resoc/trunk/includes/class-resoc-utils.php

    r2544870 r2548884  
    130130    }
    131131  }
     132
     133  public static function hash_request( $request ) {
     134    return sha1( print_r( $request, true ) );
     135  }
    132136}
  • resoc/trunk/includes/class-resoc.php

    r2544870 r2548884  
    117117        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-resoc-utils.php';
    118118
     119        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-resoc-compatibility.php';
     120
    119121        /**
    120122         * The class responsible for defining all actions that occur in the admin area.
     
    225227    }
    226228
    227   const POST_META_OG_IMAGE_ID = 'resoc_og_image_id';
     229  const POST_META_OG_IMAGE_ID         = 'resoc_og_image_id';
     230  const POST_META_LATEST_REQUEST_HASH = 'resoc_latest_request_hash';
    228231}
  • resoc/trunk/public/class-resoc-public.php

    r2544870 r2548884  
    5353        $this->version = $version;
    5454
    55     add_action( 'wp_head', array( $this, 'add_opengraph_markups' ) );
     55    // Disable Jetpack Open Graph markups
     56    add_filter( 'jetpack_enable_open_graph', '__return_false' );
     57
     58    if ( Resoc_Compatibility::is_yoast_seo_active() ) {
     59      add_filter(
     60        'wpseo_add_opengraph_images',
     61        array( $this, 'get_yoast_og_image' )
     62      );
     63    }
     64    else if ( Resoc_Compatibility::is_aiosp_active() ) {
     65      add_filter(
     66        'aioseo_facebook_tags',
     67        array( $this, 'override_aiosp_image_meta' ),
     68        10, 1
     69      );
     70    }
     71    else {
     72      $conflicting_plugin = Resoc_Compatibility::conflicting_plugin();
     73
     74      if ( $conflicting_plugin ) {
     75        Resoc_Utils::log( "Conflict with " . $conflicting_plugin . ", do nothing" );
     76        return;
     77      }
     78
     79      add_action( 'wp_head', array( $this, 'add_opengraph_markups' ) );
     80    }
    5681    }
     82
     83  public function get_yoast_og_image( $wpseo_opengraph_image ) {
     84    $post_id = get_the_ID();
     85    $specific_image_id = get_post_meta(
     86      $post_id,
     87      Resoc::POST_META_OG_IMAGE_ID,
     88      true
     89    );
     90    if ( $specific_image_id ) {
     91      $wpseo_opengraph_image->add_image_by_id( $specific_image_id );
     92    }
     93  }
     94
     95  public function override_aiosp_image_meta( $facebookMeta ) {
     96    $specific_image_id = get_post_meta(
     97      get_the_ID(),
     98      Resoc::POST_META_OG_IMAGE_ID,
     99      true
     100    );
     101    if ( $specific_image_id ) {
     102      $image_data = wp_get_attachment_metadata( $specific_image_id );
     103
     104      if ( is_array( $image_data ) ) {
     105        $image_data['url'] = wp_get_attachment_image_url( $specific_image_id, 'full' );
     106        $facebookMeta['og:image'] = $image_data['url'];
     107
     108        if ( $image_data['width'] && $image_data['height'] ) {
     109          $facebookMeta['og:image:width'] = $image_data['width'];
     110          $facebookMeta['og:image:height'] = $image_data['height'];
     111        }
     112      }
     113    }
     114
     115    return $facebookMeta;
     116  }
    57117
    58118  public function add_opengraph_markups() {
  • resoc/trunk/resoc.php

    r2544884 r2548884  
    1717 * Plugin URI:        https://resoc.io/resoc-uri/
    1818 * Description:       This is a short description of what the plugin does. It's displayed in the WordPress admin area.
    19  * Version:           1.0.1
     19 * Version:           1.0.2
    2020 * Author:            Resoc
    2121 * Author URI:        https://resoc.io/
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define( 'RESOC_VERSION', '1.0.1' );
     38define( 'RESOC_VERSION', '1.0.2' );
    3939
    4040/**
Note: See TracChangeset for help on using the changeset viewer.