Changeset 1189406
- Timestamp:
- 06/29/2015 08:57:10 AM (11 years ago)
- Location:
- militant-moderates-css-parent-selector-mmps/trunk
- Files:
-
- 3 added
- 5 edited
-
css/mmParentSelector.css (modified) (2 diffs)
-
css/mmps-ccss.php (added)
-
images (added)
-
images/icon.png (added)
-
js/mmParentSelector.js (modified) (11 diffs)
-
js/mmParentSelector.min.js (modified) (2 diffs)
-
mmParentSelector.php (modified) (6 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
militant-moderates-css-parent-selector-mmps/trunk/css/mmParentSelector.css
r1188826 r1189406 1 1 /** 2 2 * @package militant-moderates-css-parent-selector-mmps 3 * @version 1. 1.43 * @version 1.2.0 4 4 */ 5 5 /* … … 7 7 Plugin URI: http://www.militantmoderates.org/mmps-quick-start/ 8 8 Description: Adds CSS "Parent Selector" support to your Theme. Apply your CSS Style to Parent/Sibling elements not just the Selected element. 9 Version: 1. 1.49 Version: 1.2.0 10 10 Author: MM Techmaster 11 11 Author URI: https://profiles.wordpress.org/mmtechmaster -
militant-moderates-css-parent-selector-mmps/trunk/js/mmParentSelector.js
r1188826 r1189406 1 1 /** 2 2 * @package militant-moderates-css-parent-selector-mmps 3 * @version 1. 1.43 * @version 1.2.0 4 4 */ 5 5 /* … … 7 7 Plugin URI: http://www.militantmoderates.org/mmps-quick-start/ 8 8 Description: Adds CSS "Parent Selector" support to your Theme. Apply your CSS Style to Parent/Sibling elements not just the Selected element. 9 Version: 1. 1.49 Version: 1.2.0 10 10 Author: MM Techmaster 11 11 Author URI: https://profiles.wordpress.org/mmtechmaster … … 27 27 */ 28 28 29 var packageName = 'militant-moderates-css-parent-selector-mmps'; 30 var packageVersion = '1.2.0'; 31 29 32 jQuery(document).ready(function( $ ) { 30 33 31 var evidx = 0, k = 0, i, j,34 var styleidx = -1, slctridx = 1, evidx = 0, clsidx = 0, 32 35 33 36 // Class that's added to every styled element … … 109 112 var ret = ''; 110 113 111 for (var i = 0; i < aryRegExp.length; i++) 114 for (var i = 0; i < aryRegExp.length; i++) { 112 115 ret += aryRegExp[i].source; 116 } 113 117 114 118 return ret; 115 119 })([ 116 120 /[\w\s\/\.\-\:\=\[\]\(\)\~\+\|\,\*\'\"\^$#>]*(?=!)/, 117 /[\w\s\/\.\-\:\=\[\]\(\)\~\+\|\,\*\'\"\^$#>!]* \{{1}/,118 / [^\}]+\}{1}/121 /[\w\s\/\.\-\:\=\[\]\(\)\~\+\|\,\*\'\"\^$#>!]*/, 122 /\{{1}[^\}]+\}{1}/ 119 123 ]), "gi"); 124 125 126 // stick debug prefix function behind a console.log so it gets stripped when they get stripped 120 127 121 128 parse = function(sRawCSS) { … … 126 133 parsed = ''; 127 134 128 for ( i = -1; ++i< matches.length; ) {129 style = $.trim(matches[ i]);135 for (styleidx = -1; ++styleidx < matches.length; ) { 136 style = $.trim(matches[styleidx]); 130 137 131 138 // parse Selector portion of Style … … 146 153 147 154 parsedSelectors = ''; 148 for ( j = -1; ++j< selectors.length; ) {149 selector = $.trim(selectors[ j]);155 for (slctridx = -1; ++slctridx < selectors.length; ) { 156 selector = $.trim(selectors[slctridx]); 150 157 151 158 (parsedSelectors.length) && (parsedSelectors += ","); … … 157 164 // Split the selector on the '!' and save results 158 165 var splitsel = selector.split('!'); 159 166 160 167 // recombine remaining array members in case a second '!' was included 161 168 if (splitsel.length > 2) … … 253 260 // If we successfully walked up the DOM tree and found the right parent... 254 261 if (subject) { 255 var id = CLASS + k++,262 var id = CLASS + clsidx++, 256 263 257 264 addNamespace = function( eType ) { … … 269 276 return false; 270 277 }, 271 278 272 279 getPseudoEvent = function( ppNorm ) { 273 280 if ( eventMap[ ppNorm ] ) … … 407 414 408 415 if (parsed.length) 409 $('<style type="text/css" mmps_ gen="yes">' + parsed + '</style>').appendTo('head');416 $('<style type="text/css" mmps_ver="' + packageVersion + '">' + parsed + '</style>').appendTo('head'); 410 417 411 418 } else { // else "if !matches" … … 456 463 } 457 464 458 $('link[rel="stylesheet"],style').each(function(i) { 459 if ($(this).is('link')) { 460 var href = $(this).attr('href'); 461 462 $.ajax({ 463 type: 'GET', 464 url: href, 465 dataType: 'text' 466 }).done(function(css) { 467 parse(css); 468 }).fail(function() { 469 }); 470 } else { 471 parse($(this).text()); 465 var parseExternal = true; 466 var parseInline = true; 467 468 $('script[src*="' + packageName + '"]').each(function() { 469 var src = $(this).attr('src').split('?'); 470 if ( src[1] ) { 471 var argv = src[1].split('&'); 472 for ( var j=0; j < argv.length; ++j ) { 473 var pair = argv[j].split('='); 474 if ( pair[0] == 'ver' ) { 475 pair = pair[1].split('+'); 476 if ( pair[0] != packageVersion ) { 477 } 478 if ( pair[1] ) { 479 if ( pair[1].indexOf('X') < 0 ) 480 parseExternal = false; 481 if ( pair[1].indexOf('I') < 0 ) 482 parseInline = false; 483 } else { 484 parseExternal = parseInline = false; 485 } 486 } 487 } 472 488 } 473 489 }); 490 491 492 $('link[rel="stylesheet"],style').each(function(i) { 493 if ( $(this).attr('mmps_rev') ) { 494 } else if ( $(this).attr('mmps_ignore') ) { 495 } else if ( $(this).is('link') ) { 496 if ( parseExternal ) { 497 var href = $(this).attr('href'); 498 $.ajax({ 499 type: 'GET', 500 url: href, 501 dataType: 'text' 502 }).done(function(css) { 503 parse(css); 504 }).fail(function() { 505 }); 506 } 507 } else if ( parseInline ) { 508 parse( $(this).text() ); 509 } 510 }); 474 511 475 512 }); -
militant-moderates-css-parent-selector-mmps/trunk/js/mmParentSelector.min.js
r1188826 r1189406 1 1 2 jQuery(document).ready(function($){var evidx=0,k=0,i,j,CLASS='mmPpSsPrEfIx',eventMap={abort:'abort',active:'focusin',click:'click',dblclick:'dblclick',focus:'focusin',focusout:'focusout',hover:'mouseover',keyup:'keyup',load:'load',mouseleave:'mouseleave',mousemove:'mousemove',mouseout:'mouseout',mouseup:'mouseup',resize:'resize',scroll:'scroll',select:'select',unload:'unload',visited:'click',wheel:'wheel',},pairedEventMap={focusin:'focusout',keydown:'keyup',mousedown:'mouseup mouseout mouseleave',mouseenter:'mouseleave',mouseover:'mouseout',},stateMap={active:':active',disabled:':disabled',empty:':empty',enabled:':enabled',first_child:':first-child',first_of_type:':first-of-type',in_range:':in-range',invalid:':invalid',lang:':lang',last_child:':last-child',last_of_type:':last-of-type',link:':link',not:':not',nth_child:':nth-child',nth_last_child:':nth-last-child',nth_last_of_type:':nth-last-of-type',nth_of_type:':nth-of-type',only_of_type:':only-of-type',only_child:':only-child',optional:':optional',out_of_range:':out-of-range',read_only:':read-only',read_write:':read-write',required:':required',target:':target',valid:':valid',visited:':visited'},pseudoElements={after:'::after',before:'::before',first_letter:'::first-letter',first_line:'::first-line',selection:'::selection'},parsed,parsedSelectors,matches,selectors,selector,parent,target,child,pseudoTargets,declarations,pseudoParent,pseudoParents,childSelector,childElements,REGEX=new RegExp((function(aryRegExp){var ret='';for(var i=0;i<aryRegExp.length;i++) 3 ret +=aryRegExp[i].source;return ret;})([/[\w\s\/\.\-\:\=\[\]\(\)\~\+\|\,\*\'\"\^$#>]*(?=!)/,/[\w\s\/\.\-\:\=\[\]\(\)\~\+\|\,\*\'\"\^$#>!]*\{{1}/,/[^\}]+\}{1}/]),"gi");parse=function(sRawCSS){sRawCSS=sRawCSS.replace(/(\/\*([\s\S]*?)\*\/)/gm,'');if(matches=sRawCSS.match(REGEX)){parsed='';for(i=-1;++i<matches.length;){style=$.trim(matches[i]);selectors=$.trim(style.split('{')[0]).split(/\s*,\s*/);declarations='{'+style.split(/\{|\}/)[1].replace(/^\s+|\s+$[\t\n\r]*/g,'')+'}';if(declarations==='{}'){continue;}2 var packageName='militant-moderates-css-parent-selector-mmps';var packageVersion='1.2.0';jQuery(document).ready(function($){var styleidx=-1,slctridx=1,evidx=0,clsidx=0,CLASS='mmPpSsPrEfIx',eventMap={abort:'abort',active:'focusin',click:'click',dblclick:'dblclick',focus:'focusin',focusout:'focusout',hover:'mouseover',keyup:'keyup',load:'load',mouseleave:'mouseleave',mousemove:'mousemove',mouseout:'mouseout',mouseup:'mouseup',resize:'resize',scroll:'scroll',select:'select',unload:'unload',visited:'click',wheel:'wheel',},pairedEventMap={focusin:'focusout',keydown:'keyup',mousedown:'mouseup mouseout mouseleave',mouseenter:'mouseleave',mouseover:'mouseout',},stateMap={active:':active',disabled:':disabled',empty:':empty',enabled:':enabled',first_child:':first-child',first_of_type:':first-of-type',in_range:':in-range',invalid:':invalid',lang:':lang',last_child:':last-child',last_of_type:':last-of-type',link:':link',not:':not',nth_child:':nth-child',nth_last_child:':nth-last-child',nth_last_of_type:':nth-last-of-type',nth_of_type:':nth-of-type',only_of_type:':only-of-type',only_child:':only-child',optional:':optional',out_of_range:':out-of-range',read_only:':read-only',read_write:':read-write',required:':required',target:':target',valid:':valid',visited:':visited'},pseudoElements={after:'::after',before:'::before',first_letter:'::first-letter',first_line:'::first-line',selection:'::selection'},parsed,parsedSelectors,matches,selectors,selector,parent,target,child,pseudoTargets,declarations,pseudoParent,pseudoParents,childSelector,childElements,REGEX=new RegExp((function(aryRegExp){var ret='';for(var i=0;i<aryRegExp.length;i++){ret+=aryRegExp[i].source;} 3 return ret;})([/[\w\s\/\.\-\:\=\[\]\(\)\~\+\|\,\*\'\"\^$#>]*(?=!)/,/[\w\s\/\.\-\:\=\[\]\(\)\~\+\|\,\*\'\"\^$#>!]*/,/\{{1}[^\}]+\}{1}/]),"gi");parse=function(sRawCSS){sRawCSS=sRawCSS.replace(/(\/\*([\s\S]*?)\*\/)/gm,'');if(matches=sRawCSS.match(REGEX)){parsed='';for(styleidx=-1;++styleidx<matches.length;){style=$.trim(matches[styleidx]);selectors=$.trim(style.split('{')[0]).split(/\s*,\s*/);declarations='{'+style.split(/\{|\}/)[1].replace(/^\s+|\s+$[\t\n\r]*/g,'')+'}';if(declarations==='{}'){continue;} 4 4 if(!/;}$/.test(declarations)) 5 declarations=declarations.replace(/}/g,';}');declarations=declarations.replace(/;/g,' !important;');parsedSelectors='';for( j=-1;++j<selectors.length;){selector=$.trim(selectors[j]);(parsedSelectors.length)&&(parsedSelectors+=",");var splitsel=selector.split('!');if(/!/.test(selector)){var splitsel=selector.split('!');if(splitsel.length>2)5 declarations=declarations.replace(/}/g,';}');declarations=declarations.replace(/;/g,' !important;');parsedSelectors='';for(slctridx=-1;++slctridx<selectors.length;){selector=$.trim(selectors[slctridx]);(parsedSelectors.length)&&(parsedSelectors+=",");var splitsel=selector.split('!');if(/!/.test(selector)){var splitsel=selector.split('!');if(splitsel.length>2) 6 6 splitsel[1]=splitsel.slice(1).join('!');var splitp=splitsel[0].split(/[>~+\s]+/).reverse()[0].split(/[\:]+/);parent=$.trim(splitp[0]);pseudoParents=splitp.slice(1);var splitt=splitsel[1].split(/[>~+\s]+/).reverse()[0].split(/[\:]+/);target=$.trim(splitt[0])||[]._;pseudoTargets=splitt.slice(1);childSelector=selector.replace(/!/g,'').replace('::',':');$(pseudoParents).each(function(){childSelector=childSelector.replace(':'+this,'');});$(pseudoTargets).each(function(){if(eventMap[this.toString()]||pairedEventMap[this.toString()]) 7 7 childSelector=childSelector.replace(':'+this,'');});childElements=childSelector.match(/([\>\+\~]|(\:not\()?((\w[\-\w]*|\*)|[\.\#]\w[\-\w]*|\:{1,2}\w[\-\w\(\)]*|\[[^\]]*\])+\)?\!?)/gi);if(childElements.length>1){var qDOM;do{qDOM=false;try{child=$(childSelector);} 8 8 catch(err){var ep=':'+$.trim(err.toString().match(/[\w\-]+$/i));if(childSelector.lastIndexOf(ep)>=0){childSelector=childSelector.replace(new RegExp(ep,'g'),'');qDOM=true;}}}while(qDOM);child.each(function(idx){var subject=$(this);var tmpNodes=childElements.slice(0,-1);;var n=$.trim(tmpNodes.pop());do{switch(n){case'>':n=$.trim(tmpNodes.pop());case'*':subject=subject.parent(n);break;case'+':n=$.trim(tmpNodes.pop());subject=subject.prev(n);break;case'~':n=$.trim(tmpNodes.pop());subject=subject.prev();while(subject&&!subject.is(n)){subject=subject.prev();} 9 break;default:subject=subject.closest(n);break;}}while(subject&&n!=parent&&(n=$.trim(tmpNodes.pop())));if(subject){var id=CLASS+ k++,addNamespace=function(eType){return eType.split(/[ ]+/).join('.e'+id+' ')+'.e'+id;},getPseudoElement=function(ppNorm){return pseudoElements[ppNorm.replace(/\-/g,'_')];},getPseudoState=function(ppNorm){var ps=ppNorm.split('(');if(stateMap[ps[0].replace(/\-/g,'_')])9 break;default:subject=subject.closest(n);break;}}while(subject&&n!=parent&&(n=$.trim(tmpNodes.pop())));if(subject){var id=CLASS+clsidx++,addNamespace=function(eType){return eType.split(/[ ]+/).join('.e'+id+' ')+'.e'+id;},getPseudoElement=function(ppNorm){return pseudoElements[ppNorm.replace(/\-/g,'_')];},getPseudoState=function(ppNorm){var ps=ppNorm.split('(');if(stateMap[ps[0].replace(/\-/g,'_')]) 10 10 return stateMap[ps[0].replace(/\-/g,'_')]+ps.slice(1).join('(');return false;},getPseudoEvent=function(ppNorm){if(eventMap[ppNorm]) 11 11 return eventMap[ppNorm];else if(pairedEventMap[ppNorm]) … … 19 19 if(parsedSelectors.length){parsedSelectors+=' '+declarations;parsed+=parsedSelectors+"\n";}} 20 20 if(parsed.length) 21 $('<style type="text/css" mmps_ gen="yes">'+parsed+'</style>').appendTo('head');}else{}};navigator.browserInfo=(function(){var ua=navigator.userAgent,tem,M=ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];if(/trident/i.test(M[1])){tem=/\brv[ :]+(\d+)/g.exec(ua)||[];return'IE '+(tem[1]||'');}21 $('<style type="text/css" mmps_ver="'+packageVersion+'">'+parsed+'</style>').appendTo('head');}else{}};navigator.browserInfo=(function(){var ua=navigator.userAgent,tem,M=ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];if(/trident/i.test(M[1])){tem=/\brv[ :]+(\d+)/g.exec(ua)||[];return'IE '+(tem[1]||'');} 22 22 if(M[1]==='Chrome'){tem=ua.match(/\b(OPR|Edge)\/(\d+)/);if(tem!=null) 23 23 return tem.slice(1).join(' ').replace('OPR','Opera');} 24 24 M=M[2]?[M[1],M[2]]:[navigator.appName,navigator.appVersion,'-?'];if((tem=ua.match(/version\/(\d+)/i))!=null)M.splice(1,1,tem[1]);return{'browser':M[0],'version':M[1]};;})();if(navigator.browserInfo.browser=="MSIE"&&navigator.browserInfo.version<=8){pseudoElements={after:':after',before:':before',first_letter:':first-letter',first_line:':first-line',selection:':selection'};stateMap={active:':active',disabled:':disabled',empty:':empty',enabled:':enabled',invalid:':invalid',lang:':lang',link:':link',not:':not',optional:':optional',required:':required',target:':target',valid:':valid',visited:':visited'};} 25 $('link[rel="stylesheet"],style').each(function(i){if($(this).is('link')){var href=$(this).attr('href');$.ajax({type:'GET',url:href,dataType:'text'}).done(function(css){parse(css);}).fail(function(){});}else{parse($(this).text());}});}); 25 var parseExternal=true;var parseInline=true;$('script[src*="'+packageName+'"]').each(function(){var src=$(this).attr('src').split('?');if(src[1]){var argv=src[1].split('&');for(var j=0;j<argv.length;++j){var pair=argv[j].split('=');if(pair[0]=='ver'){pair=pair[1].split('+');if(pair[0]!=packageVersion){} 26 if(pair[1]){if(pair[1].indexOf('X')<0) 27 parseExternal=false;if(pair[1].indexOf('I')<0) 28 parseInline=false;}else{parseExternal=parseInline=false;}}}}});$('link[rel="stylesheet"],style').each(function(i){if($(this).attr('mmps_rev')){}else if($(this).attr('mmps_ignore')){}else if($(this).is('link')){if(parseExternal){var href=$(this).attr('href');$.ajax({type:'GET',url:href,dataType:'text'}).done(function(css){parse(css);}).fail(function(){});}}else if(parseInline){parse($(this).text());}});}); -
militant-moderates-css-parent-selector-mmps/trunk/mmParentSelector.php
r1188826 r1189406 2 2 /** 3 3 * @package militant-moderates-css-parent-selector-mmps 4 * @version 1. 1.44 * @version 1.2.0 5 5 */ 6 6 /* … … 8 8 Plugin URI: http://www.militantmoderates.org/mmps-quick-start/ 9 9 Description: Adds CSS "Parent Selector" support to your Theme. Apply your CSS Style to Parent/Sibling elements not just the Selected element. 10 Version: 1. 1.410 Version: 1.2.0 11 11 Author: MM Techmaster 12 12 Author URI: https://profiles.wordpress.org/mmtechmaster … … 39 39 *-------------------------------------------------------------------------------------*/ 40 40 define( 'MMPS_SCRIPT_DEV', 0 ); // set as above: 0, 1, 2 41 define( 'MMPS_SCRIPT_VERSION', '1. 1.4' ); // set to script version number as in header41 define( 'MMPS_SCRIPT_VERSION', '1.2.0' ); // set to script version number as in header 42 42 43 43 function mmps_js() { … … 46 46 // pure CSS rules. Depends on jQuery. 47 47 48 // Here's where we get funky. The script version number is used to piggyback the option settings 49 // that control which sources of CSS will be parsed and which will be ignored. 50 // If the option to 51 $mmps_ver = ''; 52 $mmps_ccss = get_option('mmpsccss_settings'); 53 if ( !isset( $mmps_ccss[ 'mmps_ccss_parse_external' ] ) ) 54 $mmps_ver .= 'X'; 55 if ( !isset( $mmps_ccss[ 'mmps_ccss_parse_inline' ] ) ) 56 $mmps_ver .= 'I'; 57 $mmps_ver = MMPS_SCRIPT_VERSION . ( $mmps_ver != '' ? '+' . $mmps_ver : '' ); 58 48 59 // If DEBUG mode is selected and the current user has capability to activate plugins .. 49 60 // AND the .dev.js full debug version is available then ... … … 52 63 // the .dev.js version is the working copy with full debugging included 53 64 // it is NOT included in the standard distribution, so protect against attempts to use it 54 wp_enqueue_script( 'mmps_js', plugins_url( 'js/mmParentSelector.dev.js', __FILE__ ), array( 'jquery' ), MMPS_SCRIPT_VERSION);65 wp_enqueue_script( 'mmps_js', plugins_url( 'js/mmParentSelector.dev.js', __FILE__ ), array( 'jquery' ), $mmps_ver ); 55 66 56 67 } elseif ( MMPS_SCRIPT_DEV != 1 ) { 57 68 // Either in full DEBUG mode but not allowed (not an admin) or FULL version NOT specified explicitly ... 58 69 // the .min.js version is stripped of all debugging code and minified 59 wp_enqueue_script( 'mmps_js', plugins_url( 'js/mmParentSelector.min.js', __FILE__ ), array( 'jquery' ), MMPS_SCRIPT_VERSION);70 wp_enqueue_script( 'mmps_js', plugins_url( 'js/mmParentSelector.min.js', __FILE__ ), array( 'jquery' ), $mmps_ver ); 60 71 61 72 } else { 62 73 // the .js version is stripped of debugging but is NOT minified 63 wp_enqueue_script( 'mmps_js', plugins_url( 'js/mmParentSelector.js', __FILE__ ), array( 'jquery' ), MMPS_SCRIPT_VERSION);74 wp_enqueue_script( 'mmps_js', plugins_url( 'js/mmParentSelector.js', __FILE__ ), array( 'jquery' ), $mmps_ver ); 64 75 65 76 } … … 67 78 if ( file_exists( plugin_dir_path( __FILE__ ) . 'js/mmParentSelector.dev.js' ) && 68 79 file_exists( plugin_dir_path( __FILE__ ) . 'css/mmParentSelector.css' ) ) 69 wp_enqueue_style( 'mmps_js', plugins_url( 'css/mmParentSelector.css', __FILE__ ) );80 wp_enqueue_style( 'mmps_js', plugins_url( 'css/mmParentSelector.css', __FILE__ ), array(), MMPS_SCRIPT_VERSION ); 70 81 } 71 82 72 83 add_action( 'wp_enqueue_scripts', 'mmps_js' ); 73 84 85 if(!class_exists('MMPSccss')) { 86 class MMPSccss { 87 private $options; 88 89 public function __construct() { 90 add_action( 'admin_menu', array($this, 'add_menu')); 91 add_action( 'admin_init', array( $this, 'init_settings' ) ); 92 add_action( 'add_meta_boxes', array($this, 'add_meta_box' ) ); 93 add_action( 'save_post', array( $this, 'single_save' ) ); 94 add_action( 'init', array($this, 'init')); 95 add_filter( 'query_vars', array($this, 'add_wp_var')); 96 add_action( 'wp_enqueue_scripts', array($this, 'add_mmps'), 999 ); 97 add_action( 'wp_head', array($this, 'single_mmps_css')); 98 } 99 100 public function init() { 101 load_plugin_textdomain( 'mmps-ccss-add-custom-css', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); 102 } 103 104 public static function uninstall() { 105 self::delete_options(); 106 self::delete_custom_meta(); 107 } 108 109 public function add_meta_box( $post_type ) { 110 $post_types = array('post', 'page'); 111 if ( in_array( $post_type, $post_types )) { 112 // delegate to the WP function add_meta_box 113 add_meta_box( 'mmps_ccss_add_mmps', 114 __( 'Parent Selector CSS', 'mmps-ccss-add-custom-css' ), 115 array( $this, 'render_meta_box_content' ), 116 $post_type, 'advanced', 'high' 117 ); 118 } 119 } 120 121 public function single_save( $post_id ) { 122 if ( ! isset( $_POST['mmps_ccss_add_mmps_box_nonce'] ) || ! wp_verify_nonce( $_POST['mmps_ccss_add_mmps_box_nonce'], 'single_add_mmps_box' ) ) { 123 return; 124 } 125 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { 126 return; 127 } 128 if ( 'page' == $_POST['post_type'] ) { 129 if ( ! current_user_can( 'edit_page', $post_id ) ) 130 return; 131 } else { 132 if ( ! current_user_can( 'edit_post', $post_id ) ) 133 return; 134 } 135 136 $single_mmps_css = wp_kses( $_POST['single_mmps_css'], array( '\'', '\"' ) ); 137 update_post_meta( $post_id, '_single_add_mmps', $single_mmps_css ); 138 } 139 140 public function render_meta_box_content( $post ) { 141 wp_nonce_field( 'single_add_mmps_box', 'mmps_ccss_add_mmps_box_nonce' ); 142 $single_mmps_css = get_post_meta( $post->ID, '_single_add_mmps', true ); 143 echo '<p>'. sprintf( __( 'The normal CSS and Parent Selector CSS Rules entered here will always be scanned by MMPS and will be applied to this %s', 'mmps-ccss-add-custom-css' ), $post->post_type ). '</p> '; 144 echo '<textarea id="single_mmps_css" name="single_mmps_css" style="width:100%; min-height:200px;">' . esc_attr( $single_mmps_css ) . '</textarea>'; 145 } 146 147 public function add_menu() { 148 global $mmpsccss_settings_page; 149 $mmpsccss_settings_page = add_menu_page( __('Militant Moderates Parent Selector CSS - Global Settings', 'mmps-ccss-add-custom-css'), __('MMPS', 'mmps-ccss-add-custom-css'), 'manage_options', 'mmps-ccss-add-custom-css_settings', array($this, 'create_settings_page'), plugin_dir_url( __FILE__ ) . '/images/icon.png'); 150 } 151 152 public function create_settings_page() { 153 if (! current_user_can( 'manage_options' ) ) { 154 ?> 155 <div class="wrap"> 156 <h2><?php echo __('Militant Moderates Parent Selector CSS', 'mmps-ccss-add-custom-css'); ?></h2> 157 <p><?php echo __('You do not have permission to change these options.', 'mmps-ccss-add-custom-css'); ?></p> 158 </div> 159 <?php 160 } else { 161 $this->options = get_option( 'mmpsccss_settings' ); 162 ?> 163 <div class="wrap"> 164 <h2><?php echo __('Militant Moderates Parent Selector CSS', 'mmps-ccss-add-custom-css'); ?></h2> 165 <form id="mmps_ccss_form" method="post" action="options.php"> 166 <?php settings_fields( 'mmpsccss_group' ); ?> 167 <?php do_settings_sections( 'mmps-ccss-add-custom-css_settings' ); ?> 168 <?php submit_button( __('Save MMPS Settings', 'mmps-ccss-add-custom-css') ); ?> 169 </form> 170 </div> 171 <?php 172 } 173 } 174 175 public function print_parse_info() { 176 echo __('CSS Style Rules come from several different sources. Normally MMPS will scan them all<br />for Parent Selector CSS Rules. The following options allow you to choose which sources<br />will be ignored while scanning for Parent Selector CSS Rules.', 'mmps-ccss-add-custom-css'); 177 } 178 179 public function print_section_info() { 180 echo __('The following CSS Rules will apply to the entire web site. They may include both regular<br />CSS and MMPS Parent Selector CSS. Any Rules entered here will always be applied to every<br />Post and Page.', 'mmps-ccss-add-custom-css'); 181 } 182 183 public function parse_external_input() { 184 $checked_state = isset( $this->options['mmps_ccss_parse_external'] ) ? ' checked="checked"' : ''; 185 echo '<label for="mmpsccss_settings[mmps_ccss_parse_external]"><input name="mmpsccss_settings[mmps_ccss_parse_external]" id="mmpsccss_settings[mmps_ccss_parse_external]" type="checkbox"' . $checked_state . '>' . __('Check this option to IGNORE all External CSS Stylesheet files', 'mmps-ccss-add-custom-css') . '</label>'; 186 } 187 public function parse_inline_input() { 188 $checked_state = isset( $this->options['mmps_ccss_parse_inline'] ) ? ' checked="checked"' : ''; 189 echo '<label for="mmpsccss_settings[mmps_ccss_parse_inline]"><input name="mmpsccss_settings[mmps_ccss_parse_inline]" id="mmpsccss_settings[mmps_ccss_parse_inline]" type="checkbox"' . $checked_state . '>' . __('Check this option to IGNORE all Inline CSS Styles', 'mmps-ccss-add-custom-css') . '</label>'; 190 } 191 192 public function main_css_input() { 193 $custom_rules = isset( $this->options['mmps_ccss_main_style'] ) ? esc_attr( $this->options['mmps_ccss_main_style'] ) : ''; 194 echo '<textarea name="mmpsccss_settings[mmps_ccss_main_style]" style="width:100%; min-height:300px;">' . $custom_rules . '</textarea>'; 195 } 196 197 public function init_settings() { 198 register_setting( 199 'mmpsccss_group', 200 'mmpsccss_settings' 201 ); 202 add_settings_section( 203 'mmpsccss_main_parse', 204 __('Select CSS sources to IGNORE while scanning for Parent Selector Rules', 'mmps-ccss-add-custom-css'), 205 array( $this, 'print_parse_info' ), 206 'mmps-ccss-add-custom-css_settings' 207 ); 208 add_settings_field( 209 'mmps_ccss_parse_external', 210 __('Ignore external CSS files?', 'mmps-ccss-add-custom-css'), 211 array( $this, 'parse_external_input' ), 212 'mmps-ccss-add-custom-css_settings', 213 'mmpsccss_main_parse' 214 ); 215 add_settings_field( 216 'mmps_ccss_parse_inline', 217 __('Ignore inline CSS rules?', 'mmps-ccss-add-custom-css'), 218 array( $this, 'parse_inline_input' ), 219 'mmps-ccss-add-custom-css_settings', 220 'mmpsccss_main_parse' 221 ); 222 223 add_settings_section( 224 'mmpsccss_main_style', 225 __('Site-wide Parent Selector CSS Rules', 'mmps-ccss-add-custom-css'), 226 array( $this, 'print_section_info' ), 227 'mmps-ccss-add-custom-css_settings' 228 ); 229 add_settings_field( 230 'mmps_ccss_main_style', 231 __('Parent Selector CSS rules', 'mmps-ccss-add-custom-css'), 232 array( $this, 'main_css_input' ), 233 'mmps-ccss-add-custom-css_settings', 234 'mmpsccss_main_style' 235 ); 236 } 237 238 public function delete_options() { 239 unregister_setting( 240 'mmpsccss_group', 241 'mmpsccss_settings' 242 ); 243 delete_option('mmpsccss_settings'); 244 } 245 246 public function delete_custom_meta() { 247 delete_post_meta_by_key('_single_add_mmps'); 248 } 249 250 public static function add_wp_var($public_query_vars) { 251 $public_query_vars[] = 'display_mmps_ccss'; 252 return $public_query_vars; 253 } 254 255 public static function display_mmps_ccss(){ 256 $display_css = get_query_var('display_mmps_ccss'); 257 if ($display_css == 'css') { 258 include_once (plugin_dir_path( __FILE__ ) . '/css/mmps-ccss.php'); 259 exit; 260 } 261 } 262 263 public function add_mmps() { 264 $this->options = get_option( 'mmpsccss_settings' ); 265 if ( isset($this->options['mmps_ccss_main_style']) && $this->options['mmps_ccss_main_style'] != '') { 266 wp_register_style( 'mmps-ccss-add-custom-css', get_bloginfo('url') . '?display_mmps_ccss=css' ); 267 wp_enqueue_style( 'mmps-ccss-add-custom-css' ); 268 } 269 } 270 271 public function single_mmps_css() { 272 if ( is_single() || is_page() ) { 273 global $post; 274 $single_mmps_css = get_post_meta( $post->ID, '_single_add_mmps', true ); 275 if ( $single_mmps_css !== '' ) { 276 $single_mmps_css = str_replace ( array( '>', '<' ), array( '>', '<' ), $single_mmps_css ); 277 $output = "<style type=\"text/css\">\n" . $single_mmps_css . "\n</style>\n"; 278 echo $output; 279 } 280 } 281 } 282 } 283 } 284 285 if(class_exists('MMPSccss')) { 286 add_action('template_redirect', array('MMPSccss', 'display_mmps_ccss')); 287 register_uninstall_hook(__FILE__, array('MMPSccss', 'uninstall')); 288 $mmpsccss = new MMPSccss(); 289 } 290 291 if(isset($mmpsccss)) { 292 function mmpsccss_settings_link($links) { 293 $settings_link = '<a href="admin.php?page=mmps-ccss-add-custom-css_settings">' . __('Settings', 'mmps-ccss-add-custom-css') . '</a>'; 294 array_unshift($links, $settings_link); 295 return $links; 296 } 297 add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'mmpsccss_settings_link'); 298 } 299 74 300 ?> -
militant-moderates-css-parent-selector-mmps/trunk/readme.txt
r1188967 r1189406 34 34 35 35 == Changelog == 36 = 1.1.4 (in development) = 36 = 1.2.0 (in process) = 37 * Optimizations in run-time performance greatly increase load speed 38 * Added the ability to save custom CSS rules for the entire site and on a per page/post basis 39 * Added options to ignore external CSS files and inline CSS Styles 40 * (more changes coming) 41 42 = 1.1.4 (unreleased) = 37 43 * Massive rework under the event handling hood; switching to bind/unbind instead of on/off 38 44 * Handle <a> link elements differently because of the :link and :visited behavioral differences 39 45 * Added error handling around calls into the DOM that might fail under older browsers 40 * Changes in progress - Stay tuned for details 46 * *Version terminated - Rolled to 1.2.0* 41 47 42 48 = 1.1.3 =
Note: See TracChangeset
for help on using the changeset viewer.