Plugin Directory

Changeset 2571072


Ignore:
Timestamp:
07/23/2021 05:43:34 PM (5 years ago)
Author:
mottodesignstudio
Message:

Preparing for 1.3 release

Location:
social-media-library/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • social-media-library/trunk/assets/js/media-filter.js

    r2567475 r2571072  
    2020            filters.all = {
    2121                // Change this: use whatever default label you'd like
    22                 text:  'All Social Media',
     22                text:  'Select Social Media Account',
    2323                props: {
    2424                    // Change this: key needs to be the WP_Query var for the taxonomy
  • social-media-library/trunk/index.php

    r2570360 r2571072  
    44 * Plugin URI:        https://github.com/wpmotto/wp-instagram-media-library
    55 * Description:       Save images from a public Instagram account to your WordPress library.
    6  * Version:           1.2
     6 * Version:           1.3
    77 * Requires at least: 5.2
    88 * Requires PHP:      7.2
     
    1616require __DIR__ . '/vendor/autoload.php';
    1717
    18 define('MOTTO_IGML_VERSION', '1.2.0' );
     18define('MOTTO_IGML_VERSION', '1.3.0' );
    1919
    2020use Motto\InstagramMediaLibrary\MediaUploads;
     
    3636
    3737    /**
    38      * Initial Run when settings are updated.
     38     * Ajax Run
    3939     */
    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
    4150
    4251    if ( !wp_next_scheduled( 'igml_cron_hook' ) )
     
    5362    }
    5463
    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 );
    5671    $images = implode('', array_map( function( $item ) use ($link) {
    5772        $html = "<li>";
  • social-media-library/trunk/readme.txt

    r2570360 r2571072  
    66Tested up to: 5.8
    77Requires PHP: 7.2
    8 Stable tag: 1.2
     8Stable tag: 1.3
    99License: GPLv2
    1010License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
    1111
    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.
     12Download images from public social media accounts to your WordPress image library. A great way to embed Instagram posts on your site.
    1313
    1414== Description ==
     
    2121- Install and activate the plugin
    2222- 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 `[igml posts_per_page="5"]`
     23- Use the included shortcode to output your most recent images `[social_feed posts_per_page="5"]`
    2424    - Attributes map directly to `WP_Query` arguments.
    2525    - 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.
    2627- 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.
    2728
    2829== 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.
    2935
    3036= 1.2 =
  • social-media-library/trunk/src/MediaUploads.php

    r2567475 r2571072  
    99    private $args;
    1010   
    11     public function __construct( Array $args )
     11    public function __construct( Array $args, $username = null )
    1212    {
    13         $this->args = array_merge([
     13        $query = [
    1414            'post_type'      => 'attachment',
    1515            'post_mime_type' => 'image',
     
    2222                    'taxonomy' => 'social_media_attachments',
    2323                    'field'    => 'slug',
    24                     'terms'    => 'instagram',
     24                    'terms'    => $username,
     25                    'operator' => 'EXISTS',
    2526                ],
    2627            ],           
    27         ], $args);
     28        ];
     29
     30        $this->args = array_merge($query, $args);
    2831    }
    2932
  • social-media-library/trunk/src/RemoteUserMedia.php

    r2567475 r2571072  
    5454                // Set Terms
    5555                wp_set_object_terms(
    56                     $attachment_id, 'instagram', 'social_media_attachments'
     56                    $attachment_id, $this->settings->username, 'social_media_attachments'
    5757                );
    5858            }
     
    8686    private function rateLimitRequests()
    8787    {
    88         sleep(30);
     88        sleep(3);
    8989    }
    9090       
     
    131131    {       
    132132        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            }
    138139
    139140            $this->saveMedia( $media );
  • social-media-library/trunk/src/Settings.php

    r2570360 r2571072  
    7373
    7474        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(
    7589            'igml_run_now',
    7690            __( 'Run Now', 'motto-igml' ),
    7791            function() {
    7892                ?>
    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>               
    80113                <?php
    81114            },
Note: See TracChangeset for help on using the changeset viewer.