Changeset 2571072
- Timestamp:
- 07/23/2021 05:43:34 PM (5 years ago)
- Location:
- social-media-library/trunk
- Files:
-
- 6 edited
-
assets/js/media-filter.js (modified) (1 diff)
-
index.php (modified) (4 diffs)
-
readme.txt (modified) (2 diffs)
-
src/MediaUploads.php (modified) (2 diffs)
-
src/RemoteUserMedia.php (modified) (3 diffs)
-
src/Settings.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
social-media-library/trunk/assets/js/media-filter.js
r2567475 r2571072 20 20 filters.all = { 21 21 // Change this: use whatever default label you'd like 22 text: ' All Social Media',22 text: 'Select Social Media Account', 23 23 props: { 24 24 // Change this: key needs to be the WP_Query var for the taxonomy -
social-media-library/trunk/index.php
r2570360 r2571072 4 4 * Plugin URI: https://github.com/wpmotto/wp-instagram-media-library 5 5 * Description: Save images from a public Instagram account to your WordPress library. 6 * Version: 1. 26 * Version: 1.3 7 7 * Requires at least: 5.2 8 8 * Requires PHP: 7.2 … … 16 16 require __DIR__ . '/vendor/autoload.php'; 17 17 18 define('MOTTO_IGML_VERSION', '1. 2.0' );18 define('MOTTO_IGML_VERSION', '1.3.0' ); 19 19 20 20 use Motto\InstagramMediaLibrary\MediaUploads; … … 36 36 37 37 /** 38 * Initial Run when settings are updated.38 * Ajax Run 39 39 */ 40 add_action( 'update_option_igml_settings', [$remote, 'uploadUnsavedMedia']); 40 add_action( 'wp_ajax_igml_run', function() use ($remote) { 41 try { 42 $remote->uploadUnsavedMedia(); 43 echo "OK"; 44 } catch( \Exception $e ) { 45 echo $e->getMessage(); 46 } 47 wp_die(); 48 } ); 49 41 50 42 51 if ( !wp_next_scheduled( 'igml_cron_hook' ) ) … … 53 62 } 54 63 55 $media = new MediaUploads( $atts ); 64 $username = null; 65 if( isset($atts['username']) ) { 66 $username = $atts['username']; 67 unset($atts['username']); 68 } 69 70 $media = new MediaUploads( $atts, $username ); 56 71 $images = implode('', array_map( function( $item ) use ($link) { 57 72 $html = "<li>"; -
social-media-library/trunk/readme.txt
r2570360 r2571072 6 6 Tested up to: 5.8 7 7 Requires PHP: 7.2 8 Stable tag: 1. 28 Stable tag: 1.3 9 9 License: GPLv2 10 10 License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html 11 11 12 Download images from public social media accounts to your WordPress image library. This is a great way to embed Instagram posts on your site without it breaking in the future.12 Download images from public social media accounts to your WordPress image library. A great way to embed Instagram posts on your site. 13 13 14 14 == Description == … … 21 21 - Install and activate the plugin 22 22 - In Settings > Media > Social Media Library, enter and save the account username you want to download from 23 - Use the included shortcode to output your most recent images `[ igmlposts_per_page="5"]`23 - Use the included shortcode to output your most recent images `[social_feed posts_per_page="5"]` 24 24 - Attributes map directly to `WP_Query` arguments. 25 25 - Use `link="social"` or `link="attachment"` to link the image. 26 - Use `username="instagramhandle"` if you've synced more than one account and want to grab only those posts. 26 27 - Currently, requests from your server may occasionally get blocked and so it's best to use a proxy. [Signup here](https://rapidapi.com/restyler/api/instagram40) and enter your API key. 27 28 28 29 == Changelog == 30 31 = 1.3 = 32 * Run sync now via ajax. 33 * Added option to search all posts. 34 * Saved account name as categories in the media library. 29 35 30 36 = 1.2 = -
social-media-library/trunk/src/MediaUploads.php
r2567475 r2571072 9 9 private $args; 10 10 11 public function __construct( Array $args )11 public function __construct( Array $args, $username = null ) 12 12 { 13 $ this->args = array_merge([13 $query = [ 14 14 'post_type' => 'attachment', 15 15 'post_mime_type' => 'image', … … 22 22 'taxonomy' => 'social_media_attachments', 23 23 'field' => 'slug', 24 'terms' => 'instagram', 24 'terms' => $username, 25 'operator' => 'EXISTS', 25 26 ], 26 27 ], 27 ], $args); 28 ]; 29 30 $this->args = array_merge($query, $args); 28 31 } 29 32 -
social-media-library/trunk/src/RemoteUserMedia.php
r2567475 r2571072 54 54 // Set Terms 55 55 wp_set_object_terms( 56 $attachment_id, 'instagram', 'social_media_attachments'56 $attachment_id, $this->settings->username, 'social_media_attachments' 57 57 ); 58 58 } … … 86 86 private function rateLimitRequests() 87 87 { 88 sleep(3 0);88 sleep(3); 89 89 } 90 90 … … 131 131 { 132 132 foreach( $medias as $media ) { 133 if( $media->getType() !== 'image' ) 134 continue; 135 136 if( $this->mediaIsSaved( $media ) ) 137 return $this->allSaved = true; 133 if( $this->mediaIsSaved( $media ) ) { 134 if( $this->settings->thorough ) 135 continue; 136 else 137 return $this->allSaved = true; 138 } 138 139 139 140 $this->saveMedia( $media ); -
social-media-library/trunk/src/Settings.php
r2570360 r2571072 73 73 74 74 add_settings_field( 75 'igml_thorough', 76 __( 'Thorough Search', 'motto-igml' ), 77 function() { 78 $options = get_option( 'igml_settings' ); 79 ?> 80 <input type="<?php echo esc_attr('checkbox') ?>" name="<?php echo esc_attr('igml_settings[thorough]') ?>" <?php checked( $options['thorough'] ?? null, 1 ); ?> value="<?php echo esc_attr('1') ?>"> 81 <p><?php _e('By default, when left unchecked, the plugin will search only the most recent posts and stop when it reaches one that has already been saved. Check this box to always search everything.', 'motto-igml') ?></p> 82 <?php 83 }, 84 'media', 85 'igml_media_section' 86 ); 87 88 add_settings_field( 75 89 'igml_run_now', 76 90 __( 'Run Now', 'motto-igml' ), 77 91 function() { 78 92 ?> 79 <input type="<?php echo esc_attr('checkbox') ?>" name="<?php echo esc_attr('igml_settings[run_now]') ?>" value="<?php echo esc_attr('1') ?>"> 93 <div style="display:inline-block"> 94 <span class="spinner"></span> 95 <button type="button" id="mottoIgmlRunNow" class="<?php echo esc_attr('button') ?>"> 96 <?php _e('Run Now', 'motto-igml') ?> 97 </button> 98 </div> 99 <script type="text/javascript" > 100 jQuery(document).ready(function($) { 101 $("#mottoIgmlRunNow").on('click', function() { 102 var spinner = $(this).siblings('.spinner'); 103 spinner.addClass('is-active'); 104 jQuery.post(ajaxurl, { 105 'action': 'igml_run', 106 }, function(response) { 107 spinner.removeClass('is-active'); 108 console.log(response); 109 }); 110 }); 111 }); 112 </script> 80 113 <?php 81 114 },
Note: See TracChangeset
for help on using the changeset viewer.