Changeset 2548884
- Timestamp:
- 06/16/2021 11:48:48 AM (5 years ago)
- Location:
- resoc/trunk
- Files:
-
- 8 edited
-
README.txt (modified) (2 diffs)
-
admin/class-resoc-admin.php (modified) (3 diffs)
-
admin/class-resoc-settings.php (modified) (2 diffs)
-
admin/css/resoc-admin.css (modified) (1 diff)
-
includes/class-resoc-utils.php (modified) (1 diff)
-
includes/class-resoc.php (modified) (2 diffs)
-
public/class-resoc-public.php (modified) (1 diff)
-
resoc.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
resoc/trunk/README.txt
r2544884 r2548884 5 5 Requires at least: 5.0 6 6 Tested up to: 5.7.2 7 Stable tag: 1.0. 17 Stable tag: 1.0.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 81 81 == Changelog == 82 82 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 83 89 = 1.0.1 = 84 90 * Minor fix in post save -
resoc/trunk/admin/class-resoc-admin.php
r2544884 r2548884 66 66 } 67 67 68 if ( wp_is_post_autosave( $post_ID ) ) {69 Resoc_Utils::log( "Post " . $post_ID . " is autosaving, skip" );70 return;71 }72 73 68 $feature_image_url = Resoc_Utils::get_post_featured_image_url( $post_ID ); 74 69 if ( !$feature_image_url ) { … … 96 91 ); 97 92 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 98 100 $social_image = Resoc_Utils::create_social_image( $request ); 99 101 if ( !$social_image ) { … … 112 114 113 115 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 ); 114 118 115 119 Resoc_Utils::log( "OpenGraph image " . $social_image_id . " attached to post " . $post_ID ); -
resoc/trunk/admin/class-resoc-settings.php
r2544870 r2548884 87 87 } 88 88 89 if ( Resoc_Compatibility::conflicting_plugin() ) { 90 include_once( plugin_dir_path(__FILE__) . 'partials' . DIRECTORY_SEPARATOR . 'appearance-conflict-fallback.php' ); 91 return; 92 } 93 89 94 include_once( plugin_dir_path(__FILE__) . 'partials' . DIRECTORY_SEPARATOR . 'appearance.php' ); 90 95 } … … 167 172 </p> 168 173 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 → 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 ?> 184 177 185 178 <p> -
resoc/trunk/admin/css/resoc-admin.css
r2544870 r2548884 51 51 display: none; 52 52 } 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 130 130 } 131 131 } 132 133 public static function hash_request( $request ) { 134 return sha1( print_r( $request, true ) ); 135 } 132 136 } -
resoc/trunk/includes/class-resoc.php
r2544870 r2548884 117 117 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-resoc-utils.php'; 118 118 119 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-resoc-compatibility.php'; 120 119 121 /** 120 122 * The class responsible for defining all actions that occur in the admin area. … … 225 227 } 226 228 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'; 228 231 } -
resoc/trunk/public/class-resoc-public.php
r2544870 r2548884 53 53 $this->version = $version; 54 54 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 } 56 81 } 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 } 57 117 58 118 public function add_opengraph_markups() { -
resoc/trunk/resoc.php
r2544884 r2548884 17 17 * Plugin URI: https://resoc.io/resoc-uri/ 18 18 * Description: This is a short description of what the plugin does. It's displayed in the WordPress admin area. 19 * Version: 1.0. 119 * Version: 1.0.2 20 20 * Author: Resoc 21 21 * Author URI: https://resoc.io/ … … 36 36 * Rename this for your plugin and update it as you release new versions. 37 37 */ 38 define( 'RESOC_VERSION', '1.0. 1' );38 define( 'RESOC_VERSION', '1.0.2' ); 39 39 40 40 /**
Note: See TracChangeset
for help on using the changeset viewer.