Plugin Directory

Changeset 2567475


Ignore:
Timestamp:
07/19/2021 05:10:56 PM (5 years ago)
Author:
mottodesignstudio
Message:

Preparing for 1.1.0 release

Location:
social-media-library/trunk
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • social-media-library/trunk/index.php

    r2560071 r2567475  
    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.0.1
     6 * Version:           1.1.0
    77 * Requires at least: 5.2
    88 * Requires PHP:      7.2
     
    2828    $remote = new RemoteUserMedia( $settings );
    2929
     30    /**
     31     * Setup Cron Job
     32     */
    3033    add_action(
    3134        'igml_cron_hook', [$remote, 'uploadUnsavedMedia']
     35    );
     36
     37    /**
     38     * Initial Run when settings are updated.
     39     */
     40    add_action(
     41        'update_option_igml_settings', [$remote, 'uploadUnsavedMedia']
    3242    );
    3343
     
    5565    return $where;
    5666}, 10, 2 );
     67
     68 
     69add_action( 'wp_enqueue_media', function() {
     70    wp_enqueue_script(
     71        'media-library-taxonomy-filter',
     72        plugin_dir_url(__FILE__) . 'assets/js/media-filter.js',
     73        ['media-editor', 'media-views']
     74    );
     75    // Load 'terms' into a JavaScript variable that collection-filter.js has access to
     76    wp_localize_script( 'media-library-taxonomy-filter', 'MediaLibraryTaxonomyFilterData', array(
     77        'terms'     => get_terms( 'social_media_attachments', array( 'hide_empty' => false ) ),
     78    ) );
     79    // Overrides code styling to accommodate for a third dropdown filter
     80    add_action( 'admin_footer', function(){
     81        ?>
     82        <style>
     83        .media-modal-content .media-frame select.attachment-filters {
     84            max-width: -webkit-calc(33% - 12px);
     85            max-width: calc(33% - 12px);
     86        }
     87        </style>
     88        <?php
     89    });
     90});
     91
     92add_action( 'init', function() {     
     93    register_taxonomy('social_media_attachments', ['attachment'], [
     94        'hierarchical'      => false,
     95        'show_ui'           => false,
     96        'show_in_nav_menus' => false,
     97        'query_var'         => is_admin(),
     98        'rewrite'           => false,
     99        'public'            => false,
     100        'label'             => _x( 'Social Media Attachment', 'Taxonomy name', 'motto-igml' ),
     101    ]);
     102}, 0 );
     103 
  • social-media-library/trunk/readme.txt

    r2560071 r2567475  
    44Donate link: https://motto.ca
    55Requires at least: 4.8
    6 Tested up to: 5.7
     6Tested up to: 5.8
    77Requires PHP: 7.2
    8 Stable tag: 1.0.1
     8Stable tag: 1.1.0
    99License: GPLv2
    1010License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
     
    2424== Changelog ==
    2525
     26= 1.1 =
     27* Moved social network meta from post content to attachment meta.
     28* Added filter in Media Library to view by network.
     29
    2630= 1.0 =
    2731* First version.
  • social-media-library/trunk/src/Image.php

    r2560071 r2567475  
    88
    99    protected $post;
     10    protected $social;
    1011
    1112    public function __construct( WP_Post $post )
    1213    {
    1314        $this->post = $post;
     15        $this->social = wp_get_attachment_metadata( $this->post->ID )['social'];
    1416    }
    1517
     
    2426    }
    2527
     28    public function social( $prop = null )
     29    {
     30        if( isset($this->social[$prop]) )
     31            return $this->social[$prop];
     32
     33        return $this->social;
     34    }
     35
    2636    public function html( $size = 'full' )
    2737    {
     
    2939    }
    3040
    31     public function src( $size = 'full' )
     41    public function src( $size = 'full', $array = false )
    3242    {
    33         return wp_get_attachment_image_src($this->post->ID, $size);
     43        $img = wp_get_attachment_image_src($this->post->ID, $size);
     44        if( $array )
     45            return $img;
     46       
     47        return $img[0];
    3448    }
    3549}
  • social-media-library/trunk/src/MediaUploads.php

    r2555949 r2567475  
    1818            'posts_per_page' => 10,
    1919            'post_status' => 'inherit',
    20             'guid_ends_with' => '_ig_media.jpg'
     20            'tax_query' => [
     21                [
     22                    'taxonomy' => 'social_media_attachments',
     23                    'field'    => 'slug',
     24                    'terms'    => 'instagram',
     25                ],
     26            ],           
    2127        ], $args);
    2228    }
  • social-media-library/trunk/src/RemoteUserMedia.php

    r2555949 r2567475  
    4040                'post_date' => date('Y-m-d H:i:s', $media->getCreatedTime()),
    4141                'post_name' => $media->getId(),
    42                 'post_content' => serialize($media),
    4342                'post_status' => 'inherit',
    4443                'guid' => $upload_file['url'],
    4544            );
    4645   
     46           
    4747            $attachment_id = wp_insert_attachment( $attachment, $upload_file['file'], $parent_post_id );
    4848            if (!is_wp_error($attachment_id)) {
    4949                require_once(ABSPATH . "wp-admin" . '/includes/image.php');
    5050                $attachment_data = wp_generate_attachment_metadata( $attachment_id, $upload_file['file'] );
     51                $attachment_data['social'] = $this->socialMeta($media);
    5152                wp_update_attachment_metadata( $attachment_id,  $attachment_data );
     53
     54                // Set Terms
     55                wp_set_object_terms(
     56                    $attachment_id, 'instagram', 'social_media_attachments'
     57                );
    5258            }
    5359        } else {
     
    6167        $query = "SELECT COUNT(*) FROM {$wpdb->posts} WHERE `post_name` = $id";
    6268        return !empty(intval($wpdb->get_var($query)));
     69    }
     70
     71    private function socialMeta( Media $media )
     72    {
     73        return [
     74            'id' => $media->getId(),
     75            'created' => $media->getCreatedTime(),
     76            'shortcode' => $media->getShortcode(),
     77            'link' => $media->getLink(),
     78            'thumb_tiny_url' => $media->getImageLowResolutionUrl(),
     79            'thumb_url' => $media->getImageStandardResolutionUrl(),
     80            'thumb_hires_url' => $media->getImageHighResolutionUrl(),
     81            'square_images' => $media->getSquareImages(),
     82            'likes_count' => $media->getLikesCount(),
     83        ];
    6384    }
    6485
Note: See TracChangeset for help on using the changeset viewer.