forked from hlashbrooke/WordPress-Plugin-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request hlashbrooke#76 from hlashbrooke/develop
Merging WPCS and TravisCI changes
- Loading branch information
Showing
18 changed files
with
956 additions
and
572 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
node* | ||
vendor* | ||
vendor* | ||
.gitignore | ||
.vscode | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
language: php | ||
|
||
matrix: | ||
include: | ||
- php: '7.2' | ||
env: SNIFF=1 | ||
- php: '7.1' | ||
env: SNIFF=1 | ||
allow_failures: | ||
- php: '5.6' | ||
env: SNIFF=1 | ||
- php: '7.0' | ||
env: SNIFF=1 | ||
- php: 'nightly' | ||
env: SNIFF=1 | ||
|
||
before_install: | ||
- if [[ "$SNIFF" == "1" ]]; then export PHPCS_DIR=$PWD/vendor/bin; fi | ||
- if [[ "$SNIFF" == "1" ]]; then export SNIFFS_DIR=$PWD/vendor/wp-coding-standards/wpcs; fi | ||
- composer install | ||
- composer update | ||
- ./vendor/bin/phpcs --config-set installed_paths $SNIFFS_DIR | ||
- ./vendor/bin/phpcs -i | ||
- if [[ "$SNIFF" == "1" ]]; then ./vendor/bin/phpcs --config-set installed_paths $SNIFFS_DIR; fi | ||
|
||
script: | ||
- export SNIFFS_IGNORE=*/node/*,*/vendor/*,*Gruntfile.js*,*.min.js*,*.min.css*,*.less* | ||
- if [[ "$SNIFF" == "1" ]]; then ./vendor/bin/phpcs -p . --standard=WordPress --ignore=$SNIFFS_IGNORE; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* phpcs:ignore */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* phpcs:ignore */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
jQuery( document ).ready( function ( e ) { | ||
|
||
}); | ||
/** | ||
* Plugin Template admin js. | ||
* | ||
* @package WordPress Plugin Template/JS | ||
*/ | ||
|
||
jQuery( document ).ready( | ||
function ( e ) { | ||
|
||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
jQuery( document ).ready( function ( e ) { | ||
|
||
}); | ||
/** | ||
* Plugin Template frontend js. | ||
* | ||
* @package WordPress Plugin Template/JS | ||
*/ | ||
|
||
jQuery( document ).ready( | ||
function ( e ) { | ||
|
||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,96 @@ | ||
jQuery(document).ready(function($) { | ||
/** | ||
* Plugin Template js settings. | ||
* | ||
* @package WordPress Plugin Template/Settings | ||
*/ | ||
|
||
/***** Colour picker *****/ | ||
jQuery( document ).ready( | ||
function ($) { | ||
|
||
$('.colorpicker').hide(); | ||
$('.colorpicker').each( function() { | ||
$(this).farbtastic( $(this).closest('.color-picker').find('.color') ); | ||
}); | ||
/***** Colour picker *****/ | ||
|
||
$('.color').click(function() { | ||
$(this).closest('.color-picker').find('.colorpicker').fadeIn(); | ||
}); | ||
$( '.colorpicker' ).hide(); | ||
$( '.colorpicker' ).each( | ||
function () { | ||
$( this ).farbtastic( $( this ).closest( '.color-picker' ).find( '.color' ) ); | ||
} | ||
); | ||
|
||
$(document).mousedown(function() { | ||
$('.colorpicker').each(function() { | ||
var display = $(this).css('display'); | ||
if ( display == 'block' ) | ||
$(this).fadeOut(); | ||
}); | ||
}); | ||
$( '.color' ).click( | ||
function () { | ||
$( this ).closest( '.color-picker' ).find( '.colorpicker' ).fadeIn(); | ||
} | ||
); | ||
|
||
$( document ).mousedown( | ||
function () { | ||
$( '.colorpicker' ).each( | ||
function () { | ||
var display = $( this ).css( 'display' ); | ||
if (display == 'block') { | ||
$( this ).fadeOut(); | ||
} | ||
} | ||
); | ||
} | ||
); | ||
|
||
/***** Uploading images *****/ | ||
/***** Uploading images *****/ | ||
|
||
var file_frame; | ||
var file_frame; | ||
|
||
jQuery.fn.uploadMediaFile = function( button, preview_media ) { | ||
var button_id = button.attr('id'); | ||
var field_id = button_id.replace( '_button', '' ); | ||
var preview_id = button_id.replace( '_button', '_preview' ); | ||
jQuery.fn.uploadMediaFile = function (button, preview_media) { | ||
var button_id = button.attr( 'id' ); | ||
var field_id = button_id.replace( '_button', '' ); | ||
var preview_id = button_id.replace( '_button', '_preview' ); | ||
|
||
// If the media frame already exists, reopen it. | ||
if ( file_frame ) { | ||
file_frame.open(); | ||
return; | ||
} | ||
// If the media frame already exists, reopen it. | ||
if (file_frame) { | ||
file_frame.open(); | ||
return; | ||
} | ||
|
||
// Create the media frame. | ||
file_frame = wp.media.frames.file_frame = wp.media({ | ||
title: jQuery( this ).data( 'uploader_title' ), | ||
button: { | ||
text: jQuery( this ).data( 'uploader_button_text' ), | ||
}, | ||
multiple: false | ||
}); | ||
// Create the media frame. | ||
file_frame = wp.media.frames.file_frame = wp.media( | ||
{ | ||
title: jQuery( this ).data( 'uploader_title' ), | ||
button: { | ||
text: jQuery( this ).data( 'uploader_button_text' ), | ||
}, | ||
multiple: false | ||
} | ||
); | ||
|
||
// When an image is selected, run a callback. | ||
file_frame.on( 'select', function() { | ||
attachment = file_frame.state().get('selection').first().toJSON(); | ||
jQuery("#"+field_id).val(attachment.id); | ||
if( preview_media ) { | ||
jQuery("#"+preview_id).attr('src',attachment.sizes.thumbnail.url); | ||
} | ||
file_frame = false; | ||
}); | ||
// When an image is selected, run a callback. | ||
file_frame.on( | ||
'select', | ||
function () { | ||
attachment = file_frame.state().get( 'selection' ).first().toJSON(); | ||
jQuery( "#" + field_id ).val( attachment.id ); | ||
if (preview_media) { | ||
jQuery( "#" + preview_id ).attr( 'src', attachment.sizes.thumbnail.url ); | ||
} | ||
file_frame = false; | ||
} | ||
); | ||
|
||
// Finally, open the modal | ||
file_frame.open(); | ||
} | ||
// Finally, open the modal. | ||
file_frame.open(); | ||
} | ||
|
||
jQuery('.image_upload_button').click(function() { | ||
jQuery.fn.uploadMediaFile( jQuery(this), true ); | ||
}); | ||
jQuery( '.image_upload_button' ).click( | ||
function () { | ||
jQuery.fn.uploadMediaFile( jQuery( this ), true ); | ||
} | ||
); | ||
|
||
jQuery('.image_delete_button').click(function() { | ||
jQuery(this).closest('td').find( '.image_data_field' ).val( '' ); | ||
jQuery(this).closest('td').find( '.image_preview' ).remove(); | ||
return false; | ||
}); | ||
jQuery( '.image_delete_button' ).click( | ||
function () { | ||
jQuery( this ).closest( 'td' ).find( '.image_data_field' ).val( '' ); | ||
jQuery( this ).closest( 'td' ).find( '.image_preview' ).remove(); | ||
return false; | ||
} | ||
); | ||
|
||
}); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "hlashbrooke/wordpress-plugin-template", | ||
"license": "GPL-2.0-or-later", | ||
"description": "A robust code template for creating a standards-compliant WordPress plugin.", | ||
"keywords": [ | ||
"wordpress", "wp", "plugin template" | ||
], | ||
"support": { | ||
"issues": "https://github.com/hlashbrooke/WordPress-Plugin-Template" | ||
}, | ||
"require": { | ||
"php": ">=5.4", | ||
"squizlabs/php_codesniffer": "^3.3.1" | ||
}, | ||
"require-dev": { | ||
"wp-coding-standards/wpcs": "2.1.*" | ||
} | ||
} |
Oops, something went wrong.