Changeset 896114
- Timestamp:
- 04/17/2014 12:23:42 PM (12 years ago)
- Location:
- wp-js-detect/trunk
- Files:
-
- 2 added
- 1 deleted
- 6 edited
-
.travis.yml (modified) (2 diffs)
-
bin/install-wp-tests.sh (modified) (2 diffs)
-
bootstrap_tests.php (added)
-
phpunit.xml (modified) (1 diff)
-
readme.md (modified) (1 diff)
-
readme.txt (deleted)
-
tests/bootstrap.php (modified) (1 diff)
-
tests/test-WordPressPluginTest.php (added)
-
wp-js-detect.php (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-js-detect/trunk/.travis.yml
r891421 r896114 1 # http://docs.travis-ci.com/user/build-configuration/ 1 2 language: php 2 3 3 4 php: 4 - 5.25 5 - 5.3 6 6 - 5.4 … … 8 8 env: 9 9 - WP_VERSION=latest WP_MULTISITE=0 10 - WP_VERSION=latest WP_MULTISITE=1 10 # - WP_VERSION=latest WP_MULTISITE=1 11 12 # whitelist 13 branches: 14 only: 15 - master 16 17 before_install: 18 # Use this to prepare the system to install prerequisites or dependencies 19 # e.g. sudo apt-get update 20 21 install: 22 # Use this to install any prerequisites or dependencies necessary to run your build 23 24 ## PHP Copy/Paste Detector 25 # - curl -o phpcpd.phar https://phar.phpunit.de/phpcpd.phar 26 27 - wget https://phar.phpunit.de/phpcpd.phar 28 - chmod +x phpcpd.phar 29 - sudo mv phpcpd.phar /usr/local/bin/phpcpd 11 30 12 31 before_script: 13 - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION 32 # Use this to prepare your build for testing 33 # e.g. copy database configurations, environment variables, etc. 14 34 15 script: phpunit 35 # FUCK COMPOSER/TRAVIS 36 # ## Composer 37 # - sudo apt-get -qq install dnsutils 38 # - curl -s http://getcomposer.org/installer | php 39 # - php composer.phar install 40 # - composer self-update 41 42 ## PHP_CodeSniffer 43 - pear install pear/PHP_CodeSniffer 44 - phpenv rehash 45 - git clone git://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git $(pear config-get php_dir)/PHP/CodeSniffer/Standards/WordPress 46 47 ## PHP Mess Detector 48 - pear config-set preferred_state beta 49 - printf "\n" | pecl install imagick 50 - pear channel-discover pear.phpmd.org 51 - pear channel-discover pear.pdepend.org 52 - pear install --alldeps phpmd/PHP_PMD 53 - phpenv rehash 54 ## PHPLOC 55 - curl -o phploc.phar https://phar.phpunit.de/phploc.phar 56 57 script: 58 59 - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION 60 - phpunit 61 62 notifications: 63 email: 64 [email protected] 65 66 after_success: 67 after_failure: 68 after_script: -
wp-js-detect/trunk/bin/install-wp-tests.sh
r874121 r896114 30 30 31 31 wget -nv -O $WP_CORE_DIR/wp-content/db.php https://raw.github.com/markoheijnen/wp-mysqli/master/db.php 32 33 cd $WP_CORE_DIR/wp-content/plugins 34 35 array=( "wp-js-detect" ) 36 for element in ${array[@]} 37 do 38 svn co --quiet http://plugins.svn.wordpress.org/$element temporary_plugin_copy 39 mkdir $element 40 cp -r temporary_plugin_copy/trunk/* $element 41 rm -rf temporary_plugin_copy 42 done 43 44 32 45 } 33 46 … … 74 87 } 75 88 89 php_tools() { 90 91 ## PHP_CodeSniffer 92 # - phpcs --standard=PSR1 . 93 # - phpcs --standard=PSR2 . 94 phpcs --standard=WordPress $WP_CORE_DIR"wp-content/plugins/wp-js-detect/wp-js-detect.php" 95 96 ## PHP Copy/Paste Detector 97 phpcpd --verbose $WP_CORE_DIR"wp-content/plugins/wp-js-detect/" 98 99 ## PHP Mess Detector 100 phpmd $WP_CORE_DIR"wp-content/plugins/wp-js-detect/" text cleancode --exclude lightopenid 101 phpmd $WP_CORE_DIR"wp-content/plugins/wp-js-detect/" text codesize --exclude lightopenid 102 phpmd $WP_CORE_DIR"wp-content/plugins/wp-js-detect/" text controversial --exclude lightopenid 103 phpmd $WP_CORE_DIR"wp-content/plugins/wp-js-detect/" text design --exclude lightopenid 104 phpmd $WP_CORE_DIR"wp-content/plugins/wp-js-detect/" text naming --exclude lightopenid 105 phpmd $WP_CORE_DIR"wp-content/plugins/wp-js-detect/" text unusedcode --exclude lightopenid 106 107 ## PHPLOC 108 php phploc.phar $WP_CORE_DIR"wp-content/plugins/wp-js-detect/wp-js-detect.php" 109 } 110 76 111 install_wp 77 112 install_test_suite 78 113 install_db 114 php_tools -
wp-js-detect/trunk/phpunit.xml
r874121 r896114 1 1 <phpunit 2 bootstrap=" tests/bootstrap.php"2 bootstrap="bootstrap_tests.php" 3 3 backupGlobals="false" 4 4 colors="true" -
wp-js-detect/trunk/readme.md
r891421 r896114 5 5 - Tags: javascript,js, disabled js,disabled javascript,disabled javascript notification,disabled javascript message, warning 6 6 - Requires at least: 3.5 7 - Tested up to: 3. 87 - Tested up to: 3.9 8 8 - Stable tag: 1.0.9 9 9 - License: GPLv2 or later -
wp-js-detect/trunk/tests/bootstrap.php
r874121 r896114 1 1 <?php 2 2 3 $_tests_dir = getenv('WP_TESTS_DIR'); 4 if ( !$_tests_dir ) $_tests_dir = '/tmp/wordpress-tests-lib'; 3 /** 4 * Bootstrap the plugin unit testing environment. Customize 'active_plugins' 5 * setting below to point to your main plugin file. 6 * 7 * Requires WordPress Unit Tests (http://unit-test.svn.wordpress.org/trunk/). 8 * 9 * @package wordpress-plugin-tests 10 */ 5 11 6 require_once $_tests_dir . '/includes/functions.php'; 12 // Add this plugin to WordPress for activation so it can be tested. 7 13 8 function _manually_load_plugin() { 9 require dirname( __FILE__ ) . '/../wp-js-detect.php'; 14 $GLOBALS['wp_tests_options'] = array( 15 'active_plugins' => array( "wp-js-detect/wp-js-detect.php" ), 16 ); 17 18 // If the wordpress-tests repo location has been customized (and specified 19 // with WP_TESTS_DIR), use that location. This will most commonly be the case 20 // when configured for use with Travis CI. 21 22 // Otherwise, we'll just assume that this plugin is installed in the WordPress 23 // SVN external checkout configured in the wordpress-tests repo. 24 25 if( false !== getenv( 'WP_TESTS_DIR' ) ) { 26 require getenv( 'WP_TESTS_DIR' ) . '/bootstrap.php'; 27 } else { 28 require dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ) . '/bootstrap.php'; 10 29 } 11 tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );12 13 require $_tests_dir . '/includes/bootstrap.php';14 -
wp-js-detect/trunk/wp-js-detect.php
r891421 r896114 1 1 <?php 2 2 3 if ( preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {4 die( 'You are not allowed to call this page directly.');3 if ( preg_match( '#' . basename( __FILE__ ) . '#', $_SERVER['PHP_SELF'] ) ) { 4 die( 'You are not allowed to call this page directly.' ); 5 5 } 6 6 … … 36 36 * 37 37 */ 38 interface Js DetectInterface {38 interface Js_Detect_Interface { 39 39 public function __construct(); 40 40 public function install(); … … 53 53 * 54 54 */ 55 class Js Detect implements JsDetectInterface {55 class Js_Detect implements Js_Detect_Interface { 56 56 /** 57 57 * Function __construct … … 61 61 public function __construct() { 62 62 63 add_action('wp_head', array( $this, 'wp_non_js_notification'));64 add_action('admin_menu', array( $this, 'admin_menu_customization'));65 66 register_activation_hook( __FILE__, array($this, 'install'));67 register_deactivation_hook( __FILE__, array($this, 'uninstall'));68 69 $plugin = plugin_basename( __FILE__);70 add_filter("plugin_action_links_$plugin", array( $this, 'plugin_settings_link'));71 72 add_action('wp_footer', array( $this, 'add_plugin_js'), -2);73 add_action('wp_footer', array( $this, 'add_plugin_css'), -3);74 add_action('plugin_wp_js_detect_css', array( $this, 'plugin_wp_js_detect_css'));75 76 add_action('plugins_loaded', array( $this, 'js_detect_init'));63 add_action('wp_head', array( $this, 'wp_non_js_notification' ) ); 64 add_action('admin_menu', array( $this, 'admin_menu_customization' ) ); 65 66 register_activation_hook( __FILE__, array( $this, 'install' ) ); 67 register_deactivation_hook( __FILE__, array( $this, 'uninstall' ) ); 68 69 $plugin = plugin_basename( __FILE__ ); 70 add_filter("plugin_action_links_$plugin", array( $this, 'plugin_settings_link' ) ); 71 72 add_action('wp_footer', array( $this, 'add_plugin_js' ), -2 ); 73 add_action('wp_footer', array( $this, 'add_plugin_css' ), -3 ); 74 add_action('plugin_wp_js_detect_css', array( $this, 'plugin_wp_js_detect_css' ) ); 75 76 add_action('plugins_loaded', array( $this, 'js_detect_init' ) ); 77 77 } 78 78 … … 95 95 */ 96 96 public function add_plugin_css() { 97 wp_enqueue_style( 'wp-js-detect-css-dynamic', plugins_url('css/dynamic.css.php', __FILE__));97 wp_enqueue_style( 'wp-js-detect-css-dynamic', plugins_url( 'css/dynamic.css.php', __FILE__ ) ); 98 98 } 99 99 … … 106 106 */ 107 107 public function plugin_wp_js_detect_css() { 108 echo get_option( 'wp_non_js_notification_css');108 echo get_option( 'wp_non_js_notification_css' ); 109 109 } 110 110 … … 117 117 public function install() { 118 118 119 $wp_non_js_notification_text = __( 'For full functionality of this site it is necessary to enable JavaScript. Here are the <a href="http://www.enable-javascript.com/" target="_blank"> instructions how to enable JavaScript in your web browser</a>.');120 add_option( 'wp_non_js_notification_text', $wp_non_js_notification_text, '', 'yes');119 $wp_non_js_notification_text = __( 'For full functionality of this site it is necessary to enable JavaScript. Here are the <a href="http://www.enable-javascript.com/" target="_blank"> instructions how to enable JavaScript in your web browser</a>.'); 120 add_option( 'wp_non_js_notification_text', $wp_non_js_notification_text, '', 'yes' ); 121 121 122 122 $wp_non_js_notification_css = " … … 126 126 width: 100%; 127 127 height: 100%; 128 background: url(" . plugins_url('images/dark-bg.png', __FILE__ ) . ") repeat;128 background: url(" . plugins_url('images/dark-bg.png', __FILE__ ) . ") repeat; 129 129 z-index: 2000; 130 130 -webkit-transition-property: width height background-color font-size left top color; … … 148 148 box-shadow: 0 0 10px #000; 149 149 padding: 30px 30px 30px 120px; 150 background: #fef5f2 url(" . plugins_url('images/symbol_error.png', __FILE__ ) . ") 30px 50% no-repeat;150 background: #fef5f2 url(" . plugins_url('images/symbol_error.png', __FILE__ ) . ") 30px 50% no-repeat; 151 151 font-size: 20px; 152 152 text-align: left; … … 158 158 } 159 159 "; 160 add_option('wp_non_js_notification_css', $wp_non_js_notification_css, '', 'yes' );160 add_option('wp_non_js_notification_css', $wp_non_js_notification_css, '', 'yes' ); 161 161 } 162 162 … … 167 167 */ 168 168 public function uninstall() { 169 delete_option( 'wp_non_js_notification_text');170 delete_option( 'wp_non_js_notification_css');169 delete_option( 'wp_non_js_notification_text' ); 170 delete_option( 'wp_non_js_notification_css' ); 171 171 } 172 172 … … 177 177 */ 178 178 public function admin_menu_customization() { 179 add_menu_page( __('Js Detect','js-detect'), 'Js Detect', 'administrator', 'js-detect-settings', array($this, 'plugin_settings'), '', 99999999);179 add_menu_page( __( 'Js Detect','js-detect' ), 'Js Detect', 'administrator', 'js-detect-settings', array( $this, 'plugin_settings' ), '', 99999999 ); 180 180 } 181 181 … … 188 188 189 189 if ( isset( $_POST['wp_non_js_notification_text'] ) ) { 190 update_option( 'wp_non_js_notification_text', stripslashes_deep( $_POST['wp_non_js_notification_text'] ) );190 update_option( 'wp_non_js_notification_text', stripslashes_deep( $_POST['wp_non_js_notification_text'] ) ); 191 191 } 192 192 if ( isset( $_POST['wp_non_js_notification_css'] ) ) { … … 317 317 <script> 318 318 var item = document.getElementById('jsDisabled'); 319 if ( item.style.display === "block" || !item.style.display) {319 if ( item.style.display === "block" || !item.style.display ) { 320 320 item.style.display = 'none'; 321 321 } … … 370 370 371 371 $currentLocale = get_locale(); 372 if ( !empty($currentLocale) ) { 373 $moFile = dirname(__FILE__) . "/languages/" . $currentLocale . ".mo"; 374 if( @file_exists( $moFile ) && is_readable( $moFile) ) 375 load_textdomain('js-detect', $moFile); 372 if ( !empty( $currentLocale ) ) { 373 $moFile = dirname( __FILE__ ) . "/languages/" . $currentLocale . ".mo"; 374 if( @file_exists( $moFile ) && is_readable( $moFile ) ) { 375 load_textdomain( 'js-detect', $moFile ); 376 } 376 377 } 377 378 } … … 379 380 } 380 381 381 new Js Detect();382 new Js_Detect();
Note: See TracChangeset
for help on using the changeset viewer.