🔞 ADULT: Changeset/ - HD Photos!

Changeset 1919069


Ignore:
Timestamp:
08/02/2018 10:24:37 PM (7 years ago)
Author:
Kelderic
Message:

Pushing out all changes for v2.1.0. See Github release notes for details: https://github.com/Kelderic/featured-galleries/releases/tag/v2.1.0

Location:
featured-galleries/trunk
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • featured-galleries/trunk/assets/scripts/fg-admin.js

    r1916635 r1919069  
    1 (function(window) {
    2 
    3     FeaturedGalleryManager = (function( params ) {
    4 
    5         // STORE ORIGINAL BUTTON VALUES
    6 
    7         var l10nOriginal = {};
    8 
    9         /***************************************/
    10         /************* INITIALIZE **************/
    11         /***************************************/
    12 
    13         var Class = function( params ) {
    14 
    15             // STORE this AS self, SO THAT IT IS ACCESSIBLE IN SUB-FUNCTIONS AND TIMEOUTS.
    16 
    17             var self = this;
    18 
    19             // SETUP VARIABLES FROM USER-DEFINED PARAMETERS
    20 
    21             self.frame = null;
    22             self.el = {
    23                 buttonSelect: document.querySelector('#fg_select'),
    24                 buttonRemove: document.querySelector('#fg_removeall'),
    25                 modal: null,
    26                 HTMLPreview: document.querySelector('#fg-post-gallery'),
    27                 permMetadata: document.querySelector('#fg_perm_metadata'),
    28                 permNoncedata: document.querySelector('#fg_perm_noncedata'),
    29                 tempNoncedata: document.querySelector('#fg_temp_noncedata')
    30             };
    31 
    32             // STORE ORIGINAL BUTTON VALUES
    33 
    34             l10nOriginal = {
    35                 createNewGallery: wp.media.view.l10n.createNewGallery,
    36                 updateGallery: wp.media.view.l10n.updateGallery,
    37                 insertGallery: wp.media.view.l10n.insertGallery
    38             };
    39 
    40             // IF EITHER BUTTON DOESN'T EXIST, EXIT GRACEFULLY
    41 
    42             if ( ( self.el.buttonSelect == null ) || ( self.el.buttonRemove == null ) ) {
    43                 return false;
    44             }
    45 
    46             // STORE THE POST ID FOR LATER
    47 
    48             self.postID = self.el.permMetadata.dataset.post_id;
    49 
    50             // CREATE THE MEDIA FRAME
    51 
    52             self.frame = wp.media.frames.fg_frame = wp.media({
    53                 state: 'featured-gallery',
    54                 frame: 'post',
    55                 library : {
    56                     type : 'image'
    57                 }
    58             });
    59 
    60             // SPECIFY THE CUSTOM VIEW. THIS IN THEORY WOULD HAPPEN BEFORE
    61             // THE CREATING OF THE FRAME, BUT IT DOESN'T.
    62 
    63             self.frame.states.add([
    64                 new wp.media.controller.Library({
    65                     id:         'featured-gallery',
    66                     title:      'Select Images for Gallery',
    67                     priority:   20,
    68                     toolbar:    'main-gallery',
    69                     filterable: 'uploaded',
    70                     library:    wp.media.query( self.frame.options.library ),
    71                     multiple:   true,
    72                     editable:   false,
    73                     displaySettings: false,
    74                     displayUserSettings: false
    75                 }),
    76             ]);
    77 
    78             // STORE A REFERENCE TO THE WRAPPING HTML ELEMENT
    79 
    80             self.el.modal = self.frame.el;
    81 
    82             // SPECIFY ACTION FOR THE 'ready' ACTION
    83 
    84             self.frame.on('ready', function() {
    85 
    86                 self.el.modal.classList.add('no-sidebar');
    87 
    88                 fix_back_button();
    89 
    90             });
    91 
    92             // SPECIFY ACTION FOR THE 'open' ACTION
    93 
    94             self.frame.on('open', function() {
    95 
    96                 if ( self.el.permMetadata.value != '' ) {
    97 
    98                     var selection = self.frame.state().get('selection');
    99                     var imageIDs = self.el.permMetadata.value.split(',');
    100                     var editState = self.frame.state('gallery-edit');
    101                     var attachment;
    102 
    103                     // UPDATE SELECTION
    104 
    105                     imageIDs.forEach(function(imageID) {
    106                         attachment = wp.media.attachment(imageID);
    107                         attachment.fetch();
    108                         selection.add( attachment );
    109                     });
    110 
    111                     self.frame.state('gallery-edit').set( 'library', selection );
    112                     self.frame.setState('gallery-edit');
    113 
    114                     self.frame.modal.focusManager.focus();
    115 
    116                 }
    117 
    118             });
    119 
    120             // SPECIFY ACTION FOR THE 'update' ACTION. THIS HAPPENS WHEN
    121             // AN IMAGE IS SELECTED
    122 
    123             self.frame.on('update', function() {
    124 
    125                 var imageIDs = [];
    126                 var imageHTML = '';
    127 
    128                 self.frame.state().get('library').each(function(selectedImage) {
    129                     imageIDs.push(selectedImage.attributes.id);
    130                     if ( 'thumbnail' in selectedImage.attributes.sizes ) {
    131                         imageHTML += '<li><button type="button"></button><img id="' + selectedImage.attributes.id + '" src="' + selectedImage.attributes.sizes.thumbnail.url + '"></li>';
    132                     } else {
    133                         imageHTML += '<li><button type="button"></button><img id="' + selectedImage.attributes.id + '" src="' + selectedImage.attributes.sizes.full.url + '"></li>';
    134                     }
    135                 });
    136 
    137                 if ( imageIDs.length ) {
    138 
    139                     update_metabox({
    140                         HTMLPreview: imageHTML,
    141                         permMetadata: imageIDs.join(',')
    142                     }, self.el);
    143 
    144                     update_temp_metadata( self.el, self.postID );
    145 
    146                 }
    147 
    148             });
    149 
    150             self.frame.on('close', function() {
    151 
    152                 // RESET THE MAIN BUTTON TEXT
    153 
    154                 wp.media.view.l10n.createNewGallery = l10nOriginal.createNewGallery;
    155                 wp.media.view.l10n.updateGallery = l10nOriginal.updateGallery;
    156                 wp.media.view.l10n.insertGallery = l10nOriginal.insertGallery;
    157 
    158             });
    159 
    160             self.frame.on('content:render', function() {
    161 
    162                 fix_back_button();
    163 
    164             });
    165 
    166             // ADD EVENT LISTENER TO TRIGGER MEDIA MODEL WHEN USER CLICKS THE SELECT BUTTON
    167 
    168             self.el.buttonSelect.addEventListener('click', function(event){
    169 
    170                 // CUSTOMIZE THE MAIN BUTTON TEXT
    171 
    172                 wp.media.view.l10n.createNewGallery = 'Arrange Images';
    173                 wp.media.view.l10n.updateGallery = 'Set Featured Gallery';
    174                 wp.media.view.l10n.insertGallery = 'Set Featured Gallery';
    175 
    176                 // OPEN THE MODAL
    177 
    178                 self.frame.open();
    179 
    180             });
    181 
    182             self.el.buttonRemove.addEventListener('click', function(event){
    183 
    184                 update_metabox({
    185                     HTMLPreview: '',
    186                     permMetadata: ''
    187                 }, self.el);
    188 
    189                 update_temp_metadata( self.el, self.postID );
    190 
    191             });
    192 
    193             self.el.HTMLPreview.addEventListener('click', function(event){
    194 
    195                 if ( event.target.tagName.toLowerCase() == 'button' ) {
    196 
    197                     if (confirm('Are you sure you want to remove this image?')) {
    198 
    199                         // GET THE ID OF THE IMAGE THE USER WISHES TO REMOVE FROM GALLERY
    200 
    201                         var imageIDBeingRemoved = event.target.nextElementSibling.id;
    202 
    203                         // GET THE COMMA DELIMITED LIST OF IMAGE IDS IN THE GALLERY, THEN
    204                         // REMOVE THE SELECTED ID
    205 
    206                         var imageIDs = self.el.permMetadata.value;
    207                             imageIDs = imageIDs.replace( ',' + imageIDBeingRemoved, '' ).replace( imageIDBeingRemoved + ',', '' ).replace( imageIDBeingRemoved, '' );
    208 
    209                         // UPDATE THE METADATA VALUE WITH THE NEW LIST OF IMAGE IDS
    210 
    211                         self.el.permMetadata.value = imageIDs;
    212 
    213                         // REMOVE THE HTML PREVIEW
    214 
    215                         event.target.parentNode.parentNode.removeChild(event.target.parentNode);
    216 
    217                         // UPDATE THE CONTROLS
    218 
    219                         if ( self.el.permMetadata.value === '' ) {
    220 
    221                             update_metabox({
    222                                 permMetadata: ''
    223                             }, self.el);                           
    224 
    225                         }
    226 
    227                         update_temp_metadata( self.el, self.postID );
    228 
    229                     }
    230 
    231                 }
    232 
    233             });
    234 
    235         }
    236 
    237         function update_metabox( args, els ) {
    238 
    239             var HTMLPreview = null, permMetadata = null;
    240 
    241             if ( 'HTMLPreview' in args ) {
    242                 HTMLPreview = args.HTMLPreview;
    243                 els.HTMLPreview.innerHTML = args.HTMLPreview;
    244             }
    245 
    246             if ( 'permMetadata' in args ) {
    247                 permMetadata = args.permMetadata;
    248                 els.permMetadata.value = args.permMetadata;
    249             }
    250 
    251             if ( ( args.HTMLPreview === '' ) || ( args.permMetadata === '' ) ) {
    252                 els.buttonRemove.style.display = 'none';
    253                 els.buttonSelect.textContent = 'Select Images';
    254             } else {
    255                 els.buttonRemove.style.display = '';
    256                 els.buttonSelect.textContent = 'Edit Selection';
    257             }
    258 
    259         }
    260 
    261         function update_temp_metadata( els, postID ) {
    262 
    263             setTimeout(function(){
    264 
    265                 ajax({
    266                     method: 'post',
    267                     queryURL: fgInfoFromPHP.wpAdminAjaxURL,
    268                     data: {
    269                         action: 'fg_save_temp_metadata',
    270                         fg_post_id: postID,
    271                         fg_temp_noncedata: els.tempNoncedata.value,
    272                         fg_temp_metadata: els.permMetadata.value
    273                     },
    274                     success: function(serverResponse){
    275                         serverResponse = JSON.parse(serverResponse);
    276                         if ( ! serverResponse.success ) {
    277                             console.log(serverResponse.response);
    278                             alert('There was an issue with updating the live preview. Make sure that you click Save to ensure your changes aren\'t lost.');
    279                         }
    280                     },
    281                     error: function(data) {
    282                         alert('There was an issue with updating the live preview. Make sure that you click Save to ensure your changes aren\'t lost.');
    283                     }
    284                 });
    285 
    286             }, 0 );
    287 
    288         }
    289 
    290         function fix_back_button() {
    291 
    292             var backButton = document.querySelector('.media-menu a:first-child');
    293 
    294             if ( backButton ) {
    295 
    296                 backButton.textContent = '← Edit Selection';
    297                 backButton.className = 'media-menu-item button button-large';
    298 
    299             }
    300 
    301         }
    302 
    303         function ajax( params ) {
    304 
    305             var method = 'method' in params ? params['method'] : 'get';
    306             var queryURL = 'queryURL' in params ? params['queryURL'] : '';
    307             var data = 'data' in params ? params['data'] : '';
    308             var datastring = '';
    309             var successCallback = 'success' in params ? params['success'] : function(params){console.log('Successfully completed AJAX request.')};
    310             var errorCallback = 'error' in params ? params['error'] : function(params){console.log('Error during AJAX request.');};
    311             var ajaxRequest = new XMLHttpRequest();
    312 
    313             switch ( typeof data ) {
    314                 case 'string':
    315                     datastring = data;
    316                     break;
    317                 case 'object':
    318                     for ( key in data ) {
    319                         datastring += key + '=' + data[key] + '&';
    320                     }
    321                     datastring = datastring.slice(0, -1);
    322                     break;
    323             }
    324 
    325             ajaxRequest.onreadystatechange = function () {
    326                 if ( ajaxRequest.readyState === 4 ) {
    327                     if ( ajaxRequest.status === 200 ) {
    328                         successCallback(ajaxRequest.responseText, ajaxRequest.status);
    329                     } else {
    330                         errorCallback(ajaxRequest.responseText, ajaxRequest.status);
    331                     }
    332                 }
    333             };
    334 
    335             if ( method.toLowerCase() == 'post' ) {
    336 
    337                 ajaxRequest.open(method, queryURL, true);
    338 
    339                 ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    340 
    341                 ajaxRequest.send( datastring );
    342 
    343             } else {
    344 
    345                 ajaxRequest.open(method, queryURL + ( datastring == '' ? '' : '?' + datastring ), true);
    346 
    347                 ajaxRequest.send( null );
    348 
    349             }
    350 
    351         }
    352 
    353         return Class;
    354 
    355     }());
    356 
    357     document.addEventListener("DOMContentLoaded", function(event) {
    358 
    359         // INITIALIZE MANAGER WHEN DOM IS FULLY LOADED, AND ADD IT
    360         // TO WINDOW FOR DEBUGGING
    361 
    362         window.featuredGalleryManager = new FeaturedGalleryManager();
    363 
    364     });
    365 
    366 }(window));
     1!function(a){FeaturedGalleryManager=function(a){function b(a,b){"HTMLPreview"in a&&(a.HTMLPreview,b.HTMLPreview.innerHTML=a.HTMLPreview),"permMetadata"in a&&(a.permMetadata,b.permMetadata.value=a.permMetadata),""===a.HTMLPreview||""===a.permMetadata?(b.buttonRemove.style.display="none",b.buttonSelect.textContent="Select Images"):(b.buttonRemove.style.display="",b.buttonSelect.textContent="Edit Selection")}function c(a,b){setTimeout(function(){e({method:"post",queryURL:fgInfoFromPHP.wpAdminAjaxURL,data:{action:"fg_save_temp_metadata",fg_post_id:b,fg_temp_noncedata:a.tempNoncedata.value,fg_temp_metadata:a.permMetadata.value},success:function(a){a=JSON.parse(a),a.success||(console.log(a.response),alert("There was an issue with updating the live preview. Make sure that you click Save to ensure your changes aren't lost."))},error:function(a){alert("There was an issue with updating the live preview. Make sure that you click Save to ensure your changes aren't lost.")}})},0)}function d(){var a=document.querySelector(".media-menu a:first-child");a&&(a.textContent="← Edit Selection",a.className="media-menu-item button button-large")}function e(a){var b="method"in a?a.method:"get",c="queryURL"in a?a.queryURL:"",d="data"in a?a.data:"",e="",f="success"in a?a.success:function(a){console.log("Successfully completed AJAX request.")},g="error"in a?a.error:function(a){console.log("Error during AJAX request.")},h=new XMLHttpRequest;switch(typeof d){case"string":e=d;break;case"object":for(key in d)e+=key+"="+d[key]+"&";e=e.slice(0,-1)}h.onreadystatechange=function(){4===h.readyState&&(200===h.status?f(h.responseText,h.status):g(h.responseText,h.status))},"post"==b.toLowerCase()?(h.open(b,c,!0),h.setRequestHeader("Content-type","application/x-www-form-urlencoded"),h.send(e)):(h.open(b,c+(""==e?"":"?"+e),!0),h.send(null))}var f={};return function(a){var e=this;if(e.flags={},e.frame=null,e.el={buttonSelect:document.querySelector("#fg_select"),buttonRemove:document.querySelector("#fg_removeall"),modal:null,HTMLPreview:document.querySelector("#fg-post-gallery"),permMetadata:document.querySelector("#fg_perm_metadata"),permNoncedata:document.querySelector("#fg_perm_noncedata"),tempNoncedata:document.querySelector("#fg_temp_noncedata")},f=wp.media.view.l10n,"1"===fgInfoFromPHP.showDetailsSidebar||!0===fgInfoFromPHP.showDetailsSidebar?e.flags.showDetailsSidebar=!0:e.flags.showDetailsSidebar=!1,"1"===fgInfoFromPHP.useLegacySelection||!0===fgInfoFromPHP.useLegacySelection?e.flags.useLegacySelection=!0:e.flags.useLegacySelection=!1,null==e.el.buttonSelect||null==e.el.buttonRemove)return!1;e.postID=e.el.permMetadata.dataset.post_id,e.frame=wp.media.frames.fg_frame=wp.media({state:"featured-gallery",frame:"post",library:{type:"image"}}),e.frame.states.add([new wp.media.controller.Library({id:"featured-gallery",title:"Select Images for Gallery",priority:20,toolbar:"main-gallery",filterable:"uploaded",library:wp.media.query(e.frame.options.library),multiple:!!e.flags.useLegacySelection||"add",editable:!1,displaySettings:!1,displayUserSettings:!1})]),e.el.modal=e.frame.el,e.frame.on("ready",function(){e.el.modal.classList.add("fg-media-frame"),e.flags.showDetailsSidebar||e.el.modal.classList.add("no-details-sidebar"),d()}),e.frame.on("open",function(){if(""!=e.el.permMetadata.value){var a,b=e.frame.state().get("selection"),c=e.el.permMetadata.value.split(",");e.frame.state("gallery-edit");c.forEach(function(c){a=wp.media.attachment(c),a.fetch(),b.add(a)}),e.frame.state("gallery-edit").set("library",b),e.frame.setState("gallery-edit"),e.frame.modal.focusManager.focus()}}),e.frame.on("close",function(){wp.media.view.l10n=f}),e.frame.on("update",function(){var a,d,f=[],g="";e.frame.state().get("library").each(function(b){f.push(b.attributes.id),d="thumbnail"in b.attributes.sizes?b.attributes.sizes.thumbnail.url:b.attributes.url,a=b.attributes.id,g+='<li><button type="button"></button><img id="'+a+'" src="'+d+'"></li>'}),f.length&&(b({HTMLPreview:g,permMetadata:f.join(",")},e.el),c(e.el,e.postID))}),e.frame.on("content:render",function(){d()}),e.el.buttonSelect.addEventListener("click",function(a){wp.media.view.l10n.createNewGallery="Arrange Images",wp.media.view.l10n.updateGallery="Set Featured Gallery",wp.media.view.l10n.insertGallery="Set Featured Gallery",e.frame.open()}),e.el.buttonRemove.addEventListener("click",function(a){confirm("Are you sure you want to remove all images?")&&(b({HTMLPreview:"",permMetadata:""},e.el),c(e.el,e.postID))}),e.el.HTMLPreview.addEventListener("click",function(a){if("button"==a.target.tagName.toLowerCase()&&confirm("Are you sure you want to remove this image?")){var d=a.target.nextElementSibling.id,f=e.el.permMetadata.value;f=f.replace(","+d,"").replace(d+",","").replace(d,""),e.el.permMetadata.value=f,a.target.parentNode.parentNode.removeChild(a.target.parentNode),""===e.el.permMetadata.value&&b({permMetadata:""},e.el),c(e.el,e.postID)}})}}(),document.addEventListener("DOMContentLoaded",function(b){a.featuredGalleryManager=new FeaturedGalleryManager})}(window);
  • featured-galleries/trunk/assets/stylesheets/fg-admin.css

    r1916635 r1919069  
    1 /* Remove the Details Sidebar on Media Overlay */
    2 .no-sidebar .media-frame-title,
    3 .no-sidebar .media-frame-content,
    4 .no-sidebar .media-frame-router {
    5     left: 0;
    6 }
    7 
    8 .no-sidebar .media-frame-menu .media-menu a,
    9 .no-sidebar .media-frame-menu .media-menu div {
    10     display: none;
    11 }
    12 .no-sidebar.hide-router .media-frame-menu .media-menu a:first-child {
    13     display:inline-block;
    14 }
    15 
    16 .no-sidebar .media-frame-menu {
    17     top:auto;
    18     height:60px;
    19     left:16px;
    20 }
    21 
    22 .no-sidebar .media-frame-menu .media-menu {
    23     background-color:transparent;
    24     border:none;
    25     padding: 15px 0px;
    26 }
    27 
    28 #featuredgallerydiv .media-modal-icon {
    29     background-position: -95px 5px;
    30 }
    31 
    32 .media-frame-content {
    33     border-bottom: 1px solid rgb(221, 221, 221);
    34 }
    35 
    36 .media-frame-toolbar, .media-menu {
    37     border: 0;
    38     box-shadow: none;
    39 }
    40 
    41 /* Special CSS to the Select and Remove Buttons */
    42 
    43 @media screen and (min-width: 783px) {
    44     #featuredgallerydiv button {
    45         height: 32px !important;
    46         padding-top:1px !important;
    47     }
    48 }
    49 
    50 #featuredgallerydiv button {
    51     margin-top:5px !important;
    52 }
    53 
    54 #featuredgallerydiv button#fg_removeall:before {
    55     content:"\f153";
    56     font-family:"dashicons";
    57     position:relative;
    58     top:2px;
    59     left:-1px;
    60 }
    61 
    62 /* CSS to the Preview List */
    63 
    64 #featuredgallerydiv ul {
    65     margin:0;
    66 }
    67 
    68 #featuredgallerydiv ul::after {
    69     display:block;
    70     clear:both;
    71     content:"";
    72 }
    73 
    74 #featuredgallerydiv ul li {
    75     margin:0 10px 10px 0;
    76     position:relative;
    77     float:left;
    78 }
    79 
    80 #featuredgallerydiv ul li img {
    81     display:block;
    82     height:150px;
    83     width:150px;
    84     background-image: linear-gradient(45deg,rgb(196, 196, 196) 25%,transparent 25%,transparent 75%,rgb(196, 196, 196) 75%,rgb(196, 196, 196)),linear-gradient(45deg,rgb(196, 196, 196) 25%,transparent 25%,transparent 75%,rgb(196, 196, 196) 75%,rgb(196, 196, 196));
    85     background-position: 0 0,10px 10px;
    86     background-size: 20px 20px;
    87     border:solid 1px gray;
    88 }
    89 
    90 
    91 #featuredgallerydiv ul li button {
    92     cursor:pointer;
    93     display:none;
    94     position:absolute;
    95     right:5px;
    96     top:0px;
    97     background-color:transparent;
    98     font-family:"dashicons";
    99     width: 24px;
    100     height:24px !important;
    101     padding: 0px;
    102     font-size: 24px;
    103     line-height: 20px;
    104     text-align: center;
    105     color: rgb(70, 70, 70);
    106     background-color: rgb(255, 255, 255);
    107     border-width: 0px;
    108     border-radius: 3px;
    109     box-shadow: 0px 0px 0px 1px rgba(0, 0, 0, 0.3);
    110 }
    111 
    112 #featuredgallerydiv ul li:hover button {
    113     display:block;
    114 }
    115 
    116 #featuredgallerydiv ul li button:hover {
    117     box-shadow: 0px 0px 0px 1px rgba(0, 0, 0, 0.6);
    118 }
     1.fg-media-frame .media-frame-content,.fg-media-frame .media-frame-router,.fg-media-frame .media-frame-title{left:0}.fg-media-frame .media-frame-menu{top:auto;height:60px;left:16px}.fg-media-frame .media-frame-menu .media-menu{background-color:transparent;border:none;padding:15px 0}.fg-media-frame .media-frame-menu .media-menu a,.fg-media-frame .media-frame-menu .media-menu div{display:none}.fg-media-frame.hide-router .media-frame-menu .media-menu a:first-child{display:inline-block}.fg-media-frame.no-details-sidebar .attachments-browser .attachments,.fg-media-frame.no-details-sidebar .attachments-browser .media-toolbar,.fg-media-frame.no-details-sidebar .attachments-browser .uploader-inline{right:0}.fg-media-frame.no-details-sidebar .media-frame .attachment .describe,.fg-media-frame.no-details-sidebar .media-sidebar,.fg-media-frame.no-details-sidebar .media-toolbar-secondary{display:none}.fg-media-frame .media-frame-toolbar .media-toolbar{border-top:0}.fg-media-frame .media-frame-content{border-bottom:1px solid #ddd}#featuredgallerydiv ul{margin:0}#featuredgallerydiv ul:after{display:block;clear:both;content:""}#featuredgallerydiv ul li{margin:0 10px 10px 0;position:relative;float:left}#featuredgallerydiv ul li img{display:block;height:150px;width:150px;background-image:linear-gradient(45deg,#c4c4c4 25%,transparent 0,transparent 75%,#c4c4c4 0,#c4c4c4),linear-gradient(45deg,#c4c4c4 25%,transparent 0,transparent 75%,#c4c4c4 0,#c4c4c4);background-position:0 0,10px 10px;background-size:20px 20px;border:1px solid gray}#featuredgallerydiv ul li button{cursor:pointer;display:none;position:absolute;right:5px;top:5px;background-color:transparent;font-family:dashicons;width:24px;height:24px!important;padding:0;font-size:24px;line-height:20px;text-align:center;color:#464646;background-color:#fff;border-width:0;border-radius:3px;box-shadow:0 0 0 1px rgba(0,0,0,.3)}#featuredgallerydiv ul li:hover button{display:block}#featuredgallerydiv ul li button:hover{box-shadow:0 0 0 1px rgba(0,0,0,.6)}
  • featured-galleries/trunk/featured-galleries.php

    r1916669 r1919069  
    44 * Plugin URI:        http://wordpress.org/plugins/featured-galleries/
    55 * Description:       WordPress ships with a Featured Image functionality. This adds a very similar functionality, but allows for full featured galleries with multiple images.
    6  * Version:           2.0.1
     6 * Version:           2.1.0
    77 * Author:            Andy Mercer
    8  * Author URI:        http://www.andymercer.net
     8 * Author URI:        https://github.com/Kelderic/
    99 * Text Domain:       featured-galleries
    1010 * License:           GPL-2.0+
     
    1717/***********************************************************************/
    1818
    19 define( 'FG_PLUGIN_VERSION', '2.0.0' );
     19define( 'FG_PLUGIN_VERSION', '2.1.0' );
    2020
    2121define( 'FG_PLUGIN_FILE', __FILE__ );
  • featured-galleries/trunk/includes/controller.php

    r1916635 r1919069  
    6565                // CORRECT VALUE
    6666
    67                 wp_localize_script( 'fg-script-admin', 'fgInfoFromPHP', [ 'wpAdminAjaxURL' => admin_url('admin-ajax.php') ] );
     67                wp_localize_script( 'fg-script-admin', 'fgInfoFromPHP', [
     68                    'wpAdminAjaxURL' => admin_url('admin-ajax.php'),
     69                    'showDetailsSidebar' => apply_filters( 'fg_show_sidebar', false ),
     70                    'useLegacySelection' => apply_filters( 'fg_use_legacy_selection', false )
     71                ]);
    6872
    6973                // ENQUEUE OUT STYLESHEETS
    7074
    7175                wp_enqueue_style( 'fg-style-admin', plugin_dir_url( FG_PLUGIN_FILE ) . 'assets/stylesheets/fg-admin.css', [], FG_PLUGIN_VERSION );
    72 
    73                 $showSidebar = apply_filters( 'fg_show_sidebar', false );
    74 
    75                 if ( $showSidebar = false ) {
    76 
    77                     wp_enqueue_style( 'fg-style-admin-hidesidebar', plugin_dir_url( FG_PLUGIN_FILE ) . 'assets/stylesheets/fg-admin-hidesidebar.css', [], FG_PLUGIN_VERSION );
    78 
    79                 }
    8076
    8177            }
     
    170166            <p class="howto hide-if-js">Enable Javascript to use drag and drop Media Manager. Alternatively, type in the IDs of the images that you want as part of the Featured Gallery in the above text box, separating with commas.</p>
    171167
    172             <ul id="fg-post-gallery" class="hide-if-no-js">' .$galleryHTML . '</ul>
    173 
    174             <button type="button" class="button hide-if-no-js" id="fg_removeall"' .$hideIfNoSelection . '>' . __( 'Remove All', 'featured-gallery' ) . '</button>
     168            <ul id="fg-post-gallery" class="hide-if-no-js">' . $galleryHTML . '</ul>
     169
     170            <button type="button" class="button hide-if-no-js" id="fg_removeall"' . $hideIfNoSelection . '>' . __( 'Remove All', 'featured-gallery' ) . '</button>
    175171            <button type="button" class="button hide-if-no-js" id="fg_select">' . $selectButtonText . '</button>
    176172
  • featured-galleries/trunk/includes/public-functions.php

    r1916635 r1919069  
    11<?php
    22
    3 function get_post_gallery_ids( $id = null, $maxImages = -1, $method = 'array' ) {
     3function get_post_gallery_ids( $postID = null, $maxImages = -1, $method = 'array' ) {
    44
    55    global $post;
     
    77    // CHECK TO SEE IF AN ID HAS BEEN PASSED. IF NOT, LOAD THE ID FROM $POST, IF POSSIBLE
    88
    9     if ( $id == null ) {
     9    if ( $postID == null ) {
    1010
    1111        // IF NO ID HAS BEEN PASSED, CHECK TO SEE IF WE ARE IN THE LOOP AND HAVE A $post. IF
     
    1414        if ( $post !== null ) {
    1515
    16             $id = $post->ID;
     16            $postID = $post->ID;
    1717
    1818        } else {
     
    2727    // PERM METADATA
    2828
    29     if ( is_preview( $id ) ) {
     29    if ( is_preview( $postID ) ) {
    3030
    31         $galleryString = get_post_meta( $id, 'fg_temp_metadata', 1 );
     31        $galleryString = get_post_meta( $postID, 'fg_temp_metadata', 1 );
    3232
    3333    } else {
    3434
    35         $galleryString = get_post_meta( $id, 'fg_perm_metadata', 1 );
     35        $galleryString = get_post_meta( $postID, 'fg_perm_metadata', 1 );
    3636
    3737    }
  • featured-galleries/trunk/readme.txt

    r1916669 r1919069  
    55Requires at least: 3.8.0
    66Tested up to: 4.9.7
    7 Stable tag: 2.0.1
     7Stable tag: 2.1.0
    88Requires PHP: 5.4
    99License: GPLv2 or later
     
    1616= Hello Theme Developers! =
    1717
    18 Have you ever added a Featured Image to a post and thought to yourself, 'I wish I could add more than one image this way'? Well, now you can. "Featured Galleries" mirrors the Featured Images functionality of WordPress. The only difference is that posts get an entire gallery rather than just a single image. These galleries behave almost exactly like Featured Images, and make use of  WordPress's built in Media Manager. Users can select images, define the order, and save the gallery, all through a simple drag-n-drop interface.
    19 
    20 **Note**: This is not a plugin which will add galleries to your website. This is for theme developers. It handles the backend interface for creating featured galleries, and storing them. You will still need to build a gallery on your page templates.
    21 
    22 = --Instructions to Integrate Into Themes-- =
    23 
    24 Just like with Featured Images themes will need to call a Featured Gallery in any template file where the Featured Gallery should appear. I've tried to make this as intuitive as possible.
    25 
    26 Just like WordPress comes with `get_post_thumbnail_id()` built-in, you can use `get_post_gallery_ids()` to call the Featured Gallery. As long as it is used inside the loop, it doesn't need to be passed any parameters. In that case, by default, it will return a PHP array with the ID's of all images in the post's Featured Gallery. However, you can also customize the returned value to suit your needs, with up to three parameters.
    27 
    28     get_post_gallery_ids( $postID, $maxImages, $returnType );
    29 
    30 **Parameters:**
    31 
    32 * $postID:
    33  * Type: Integer
    34  * Description: The ID of the post/page that you are loading.
    35  * Default Value: null (which becomes the post ID of the current Post, if the function is called from inside the Loop)
    36  * Possible Values: Any valid post ID, or null.
    37  
    38 * $maxImages:
    39  * Type: Integer
    40  * Description: The max number of images to return. If set to -1, all images will be returned.
    41  * Default Value: -1
    42  * Possible Values: Any integer from -1 up through infinity.
    43 
    44 * $returnType:
    45  * Type: String
    46  * Description: The format of the returned image IDs.
    47  * Default Value: 'array'
    48  * Valid Values: 'array', 'string'
    49   * 'array' will cause the function to return the image IDs as a PHP array.
    50   * 'string' will cause the function to return the image IDs as a comma delimited string.
    51 
    52 
    53 = --Examples-- =
    54 
    55 **Example 1:** Set inside the Loop. This returns all images in the Featured Gallery, as an array, then loops through to display each using an HTML `<img>` tag.
     18Have you ever added a Featured Image to a post and thought to yourself, "I wish I could add more than one image this way"? Well, now you can. Featured Galleries mirrors the Featured Images functionality of WordPress. The only difference is that posts get an entire gallery rather than just a single image. These galleries behave almost exactly like Featured Images, and make use of  WordPress's built in Media Manager. Users can select images, define the order, and save the gallery, all through a simple drag-n-drop interface.
     19
     20
     21
     22= Quick Start Guide to Integrate Into Themes =
     23
     24*For more information, see [GitHub Wiki](https://github.com/Kelderic/featured-galleries/wiki)*.
     25
     26I've tried to make this as intuitive as possible. Themes can integrate Featured Galleries in the same way they integrate Featured Images. Inside any template file where the gallery should appear, the theme will call the [`get_post_gallery_ids()`](https://github.com/Kelderic/featured-galleries/wiki/get_post_gallery_ids) function. As long as it is used inside the loop, the function doesn't need any parameters. By default, it will return an array of image IDs.
     27
     28= Example =
     29
     30Set inside the Loop. This returns all images in the Featured Gallery, as an array, then loops through to display each using an HTML `<img>` tag.
    5631
    5732    $galleryArray = get_post_gallery_ids();
     
    6338    }
    6439
    65 **Example 2:** Set inside the Loop. This behaves exactly the same as Example 1, it just has all parameters specifically set to their defaults, to demonstrate what is happening.
    66 
    67     $galleryArray = get_post_gallery_ids( null, -1, 'array' );
    68 
    69     foreach ( $galleryArray as $id ) {
    70 
    71         echo '<img src="' . wp_get_attachment_url( $id ) .'">';
    72 
    73     }
    74 
    75 **Example 3:** Set inside the Loop. This returns the first two images in the Featured Gallery, as an array, then loops through to display each using an HTML `<img>` tag.
    76 
    77     $galleryArray = get_post_gallery_ids( null, 2 );
    78 
    79     foreach ( $galleryArray as $id ) {
    80 
    81         echo '<img src="' . wp_get_attachment_url( $id ) .'">';
    82 
    83     }
    84 
    85 **Example 4:** Set outside the Loop. This uses a specified post ID (431) and returns all images in that post's Featured Gallery, as an array, then loops through to display each using an HTML `<img>` tag.
    86 
    87     $galleryArray = get_post_gallery_ids( 431 );
    88 
    89     foreach ( $galleryArray as $id ) {
    90 
    91         echo '<img src="' . wp_get_attachment_url( $id ) .'">';
    92 
    93     }
    94 
    95 **Example 5:** Set inside the Loop. This returns all images in the Featured Gallery, as an string, then echos that string to the page. I personally don't see how returning the IDs as a string is useful, but it was requested as a feature a long time ago.
    96 
    97     $galleryString = get_post_gallery_ids( null, -1, 'string' );
    98 
    99     echo $galleryString; // THIS WOULD ECHO SOMETHING LIKE: 34,6422,4364
    100 
    101 = Adding Featured Galleries to a Custom Post Type =
    102 
    103 I've included a hook to allow you to easily integrate featured galleries into a custom post type. In your theme `functions.php` file, simply add something along these lines:
    104    
    105     function add_featured_galleries_to_ctp( $post_types ) {
    106 
    107         array_push($post_types, 'custom_post_type'); // ($post_types comes in as array('post','page'). If you don't want FGs on those, you can just return a custom array instead of adding to it. )
    108 
    109         return $post_types;
    110 
    111     }
    112 
    113     add_filter('fg_post_types', 'add_featured_galleries_to_ctp' );
    114 
    115 That would add Featured Galleries to the custom post type with the slug of 'custom_post_type'. To add it to a custom post type with a slug of 'books', you'd do this:
    116 
    117     function add_featured_galleries_to_ctp( $post_types ) {
    118         array_push($post_types, 'books'); // ($post_types comes in as array('post','page'). If you don't want FGs on those, you can just return a custom array instead of adding to it. )
    119         return $post_types;
    120     }
    121     add_filter('fg_post_types', 'add_featured_galleries_to_ctp' );
    122 
    123 = Show the Sidebar In Media Manager =
    124 
    125 By default, the sidebar is hidden in the media manager/uploader popup. However, if you'd like it to be shown, there is an easy filter that you can add to your functions.php file. Example:
    126 
    127     function show_fg_sidebar( $show_sidebar ) {
    128         return true; // ($show_sidebar comes in a false)
    129     } add_filter( 'fg_show_sidebar', 'show_fg_sidebar' );
     40You can also customize the returned value from the function to suit your needs. See the full [function documentation](https://github.com/Kelderic/featured-galleries/wiki/get_post_gallery_ids) page for details.
     41
     42= Custom Post Types =
     43
     44The plugin comes with a filter to easily add Featured Galleries to custom post types. See the [`fg_post_types`](https://github.com/Kelderic/featured-galleries/wiki/fg_post_types) documentation page for details.
     45
     46= Customizing the Media Manager =
     47
     48The media manager can be customized in sevearl ways. See the [`fg_show_sidebar`](https://github.com/Kelderic/featured-galleries/wiki/fg_show_sidebar) and [`fg_use_legacy_selection`](https://github.com/Kelderic/featured-galleries/wiki/fg_use_legacy_selection) filter documentation pages for details.
    13049
    13150= Want to Help? =
     
    16887
    16988== Changelog ==
     89
     90= 2.1.0 =
     91
     92* Enhancement: Switched multi-select type from Library to Gallery. You no longer have to hold the SHIFT or CONTROL/COMMAND keys to select multiple items. To restore the old behavior, use the new `fg_use_legacy_selection` filter. See docs for details.
     93* Bugfix: Fix broken details sidebar hiding filter. The details sidebar is now properly hidden again by default, and can be shown be using the `fg_show_sidebar` filter.
     94* Under the Hood: Complete rewrite of all CSS styles. FG styles are now isolated and don't affect other media manager modals.
    17095
    17196= 2.0.1 =
Note: See TracChangeset for help on using the changeset viewer.