diff --git a/.gitignore b/.gitignore index 8eb312a..bee1b7e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules/* sass/.sass-cache/* sass/svg/intermediate/* sass/symbol/* +vendor/* diff --git a/.travis.yml b/.travis.yml index 37411a7..c1f45e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,34 +1,108 @@ +sudo: false +dist: trusty language: php -dist: precise -sudo: required notifications: email: on_success: never on_failure: change -php: -- 5.3 -- 5.6 -- 7 +cache: + directories: + - vendor + - $HOME/.composer/cache after_success: curl -L https://raw.githubusercontent.com/miya0001/travis2wpplugin/master/deploy.sh | bash env: matrix: - WP_VERSION=latest WP_MULTISITE=0 global: + - WP_TRAVISCI=travis:phpunit - SVN_REPO: https://plugins.svn.wordpress.org/indieweb-post-kinds/ - GH_REF: https://github.com/dshanske/indieweb-post-kinds.git - secure: SKEHj0zThPfUhTyTKtgNuzqPp+uvdUUcMWT0ZqyARjnOGII6dO2UDzQIUc5WolgFd/HYIFfaDzBd3+FPdDTunPiwIHxIYcyr2EjvEQLJYM1zqTAUtjEPpztemKRtrnbNd1TQgWIIqIaNk//WuYkuW7+vc/HsyyTm6PGEbHK6zj11UG8ZYT8ru/Sw+PxHebwlz3d+8H6iEvFSX/rkc1kMpntwNMoFYb9PgwhkvtJ6KkVRKu4uMCkXf6BnlVqJSAGdTn+XckDeY+pwgsWGIAPakLD9MKxAq2MMqfmCxTK8uMN3VBetlbbkT7JMaYyU95gw3+3QrcPLlmRLNdbiuguD39J820wjtflEUNCJ3Heg8JF0q4z/69s6n3LEinDxtJNesK/0G//nYjsLaKXARFfnvLSRbhZvxeePsmEWTxEGt9KvoW7iD/vnwYmf1aYeobwBfkCkvA7t5FSNUTMvI8yo33DWdOyFKdWRL0V2JaaOh0H81kaXOEBayplmDfdbNX7y77/bLU863V0JkORSsJNv7ZGl8zR77ja/s1Ep0F3d43QhIoQk40w8SckpLEx+2bUs3J2jNpBeike5cut7RuSPTt7G2AiipTfmPa666f+CsmfNAjd2MYFfB2NL5ZHwjmOuxYE6hicdKt2vwOjLa31hLY/u3bT8s346w+DzIPZmItU= matrix: include: + - php: 7.2 + - php: 7.1 + - php: 7.0 - php: 5.6 - env: WP_VERSION=latest WP_MULTISITE=1 WP_PULUGIN_DEPLOY=1 + - php: 5.6 + env: WP_PULUGIN_DEPLOY=1 + - php: 5.6 + env: WP_TRAVISCI=travis:phpcs + - php: 5.5 + - php: 5.4 + - php: 5.3 + dist: precise before_script: -- export PATH="$HOME/.composer/vendor/bin:$PATH" - | - if [[ ${TRAVIS_PHP_VERSION:0:2} == "7." ]]; then - composer global require "phpunit/phpunit=5.7.*" - elif [[ ${TRAVIS_PHP_VERSION:0:3} != "5.2" ]]; then - composer global require "phpunit/phpunit=4.8.*" + # Remove Xdebug for a huge performance increase: + if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then + phpenv config-rm xdebug.ini + else + echo "xdebug.ini does not exist" fi -- bash bin/install-wp-tests.sh wordpress root '' localhost $WP_VERSION -script: phpunit +- | + # Export Composer's global bin dir to PATH: + composer config --list --global + export PATH=`composer config --list --global | grep '\[home\]' | { read a; echo "${a#* }/vendor/bin:$PATH"; }` +- | + # Install the specified version of PHPUnit depending on the PHP version: + if [[ "$WP_TRAVISCI" == "travis:phpunit" ]]; then + case "$TRAVIS_PHP_VERSION" in + 7.2|7.1|7.0|nightly) + echo "Using PHPUnit 6.x" + composer global require "phpunit/phpunit:^6" + ;; + 5.6|5.5|5.4|5.3) + echo "Using PHPUnit 4.x" + composer global require "phpunit/phpunit:^4" + ;; + 5.2) + # Do nothing, use default PHPUnit 3.6.x + echo "Using default PHPUnit, hopefully 3.6" + ;; + *) + echo "No PHPUnit version handling for PHP version $TRAVIS_PHP_VERSION" + exit 1 + ;; + esac + fi + if [[ "$WP_TRAVISCI" == "travis:phpcs" ]] ; then + composer install + fi + +- mysql --version +- phpenv versions +- php --version +- php -m +- which phpunit +- phpunit --version +- curl --version +- grunt --version +- git --version +- svn --version +- locale -a +before_install: +- export PATH="$HOME/.composer/vendor/bin:$PATH" +- | + if [[ ! -z "$WP_VERSION" ]] ; then + set -e + bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION + set +e + fi +script: + - | + if [[ ! -z "$WP_VERSION" ]] ; then + # Run the build because otherwise there will be a bunch of warnings about + # failed `stat` calls from `filemtime()`. + echo Running with the following versions: + php -v + phpunit --version + # Run PHPUnit tests + phpunit || exit 1 + WP_MULTISITE=1 phpunit || exit 1 + fi + - | + if [[ "$WP_TRAVISCI" == "travis:phpcs" ]] ; then + ./vendor/bin/phpcs -p -s -v -n --standard=./phpcs.ruleset.xml --extensions=php + fi diff --git a/bin/patches/README.md b/bin/patches/README.md new file mode 100644 index 0000000..8ea482c --- /dev/null +++ b/bin/patches/README.md @@ -0,0 +1,2 @@ +This directory contains patches required to build +older versions of PHP on trusty. \ No newline at end of file diff --git a/bin/patches/node.patch b/bin/patches/node.patch new file mode 100644 index 0000000..e5dbab7 --- /dev/null +++ b/bin/patches/node.patch @@ -0,0 +1,51 @@ +--- ext/dom/node.c 2012-08-06 17:49:48.826716692 +0800 ++++ ext/dom/node.c 2012-08-06 17:52:47.633484660 +0800 +@@ -1895,9 +1895,17 @@ static void dom_canonicalization(INTERNA + RETVAL_FALSE; + } else { + if (mode == 0) { ++#ifdef LIBXML2_NEW_BUFFER ++ ret = xmlOutputBufferGetSize(buf); ++#else + ret = buf->buffer->use; ++#endif + if (ret > 0) { ++#ifdef LIBXML2_NEW_BUFFER ++ RETVAL_STRINGL((char *) xmlOutputBufferGetContent(buf), ret, 1); ++#else + RETVAL_STRINGL((char *) buf->buffer->content, ret, 1); ++#endif + } else { + RETVAL_EMPTY_STRING(); + } +--- ext/dom/documenttype.c 2012-08-06 18:02:16.019640870 +0800 ++++ ext/dom/documenttype.c 2012-08-06 18:06:16.612228905 +0800 +@@ -205,7 +205,13 @@ int dom_documenttype_internal_subset_rea + if (buff != NULL) { + xmlNodeDumpOutput (buff, NULL, (xmlNodePtr) intsubset, 0, 0, NULL); + xmlOutputBufferFlush(buff); ++ ++#ifdef LIBXML2_NEW_BUFFER ++ ZVAL_STRINGL(*retval, xmlOutputBufferGetContent(buff), ++ xmlOutputBufferGetSize(buff), 1); ++#else + ZVAL_STRINGL(*retval, buff->buffer->content, buff->buffer->use, 1); ++#endif + (void)xmlOutputBufferClose(buff); + return SUCCESS; + } +--- ext/simplexml/simplexml.c 2012-08-06 18:10:44.621017026 +0800 ++++ ext/simplexml/simplexml.c 2012-08-06 18:12:48.016270419 +0800 +@@ -1417,7 +1417,12 @@ SXE_METHOD(asXML) + + xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 0, ((xmlDocPtr) sxe->document->ptr)->encoding); + xmlOutputBufferFlush(outbuf); ++#ifdef LIBXML2_NEW_BUFFER ++ RETVAL_STRINGL((char *)xmlOutputBufferGetContent(outbuf), ++ xmlOutputBufferGetSize(outbuf), 1); ++#else + RETVAL_STRINGL((char *)outbuf->buffer->content, outbuf->buffer->use, 1); ++#endif + xmlOutputBufferClose(outbuf); + } + } else { diff --git a/bin/patches/openssl.patch b/bin/patches/openssl.patch new file mode 100644 index 0000000..3b0e010 --- /dev/null +++ b/bin/patches/openssl.patch @@ -0,0 +1,52 @@ +--- ext/openssl/xp_ssl.c ++++ ext/openssl/xp_ssl.c +@@ -328,10 +328,12 @@ static inline int php_openssl_setup_cryp + sslsock->is_client = 1; + method = SSLv23_client_method(); + break; ++#ifndef OPENSSL_NO_SSL2 + case STREAM_CRYPTO_METHOD_SSLv2_CLIENT: + sslsock->is_client = 1; + method = SSLv2_client_method(); + break; ++#endif + case STREAM_CRYPTO_METHOD_SSLv3_CLIENT: + sslsock->is_client = 1; + method = SSLv3_client_method(); +@@ -348,10 +350,12 @@ static inline int php_openssl_setup_cryp + sslsock->is_client = 0; + method = SSLv3_server_method(); + break; ++#ifndef OPENSSL_NO_SSL2 + case STREAM_CRYPTO_METHOD_SSLv2_SERVER: + sslsock->is_client = 0; + method = SSLv2_server_method(); + break; ++#endif + case STREAM_CRYPTO_METHOD_TLS_SERVER: + sslsock->is_client = 0; + method = TLSv1_server_method(); +@@ -629,9 +633,11 @@ static inline int php_openssl_tcp_sockop + case STREAM_CRYPTO_METHOD_SSLv23_CLIENT: + sock->method = STREAM_CRYPTO_METHOD_SSLv23_SERVER; + break; ++#ifndef OPENSSL_NO_SSL2 + case STREAM_CRYPTO_METHOD_SSLv2_CLIENT: + sock->method = STREAM_CRYPTO_METHOD_SSLv2_SERVER; + break; ++#endif + case STREAM_CRYPTO_METHOD_SSLv3_CLIENT: + sock->method = STREAM_CRYPTO_METHOD_SSLv3_SERVER; + break; +@@ -911,9 +917,11 @@ php_stream *php_openssl_ssl_socket_facto + if (strncmp(proto, "ssl", protolen) == 0) { + sslsock->enable_on_connect = 1; + sslsock->method = STREAM_CRYPTO_METHOD_SSLv23_CLIENT; ++#ifndef OPENSSL_NO_SSL2 + } else if (strncmp(proto, "sslv2", protolen) == 0) { + sslsock->enable_on_connect = 1; + sslsock->method = STREAM_CRYPTO_METHOD_SSLv2_CLIENT; ++#endif + } else if (strncmp(proto, "sslv3", protolen) == 0) { + sslsock->enable_on_connect = 1; + sslsock->method = STREAM_CRYPTO_METHOD_SSLv3_CLIENT; diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..d3f0f29 --- /dev/null +++ b/composer.json @@ -0,0 +1,10 @@ +{ + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4", + "wimg/php-compatibility": "dev-master", + "wp-coding-standards/wpcs": "dev-master" + }, + "scripts": { + "lint": "phpcs" + } +} diff --git a/includes/class-kind-config.php b/includes/class-kind-config.php index 5d6328e..9ffe7f3 100644 --- a/includes/class-kind-config.php +++ b/includes/class-kind-config.php @@ -70,8 +70,10 @@ public static function init() { public static function admin_init() { add_settings_section( 'iwt-content', - __( 'Content Options', - 'indieweb-post-kinds' ), + __( + 'Content Options', + 'indieweb-post-kinds' + ), array( 'Kind_Config', 'options_callback' ), 'iwt_options' ); @@ -94,26 +96,27 @@ public static function admin_init() { 'embeds', __( 'Embed Sites into your Response', 'indieweb-post-kinds' ), array( 'Kind_Config', 'checkbox_callback' ), - 'iwt_options', 'iwt-content' , array( 'name' => 'kind_embeds' ) + 'iwt_options', 'iwt-content' , array( + 'name' => 'kind_embeds', + ) ); add_settings_field( 'display', __( 'Display Before Kind', 'indieweb-post-kinds' ), array( 'Kind_Config', 'radio_callback' ), - 'iwt_options', 'iwt-content' , - array( + 'iwt_options', 'iwt-content' , + array( 'name' => 'kind_display', 'class' => Kind_Taxonomy::before_kind() ? '' : 'hidden', 'options' => array( 'icon' => __( 'Show Icon', 'indieweb-post-kinds' ), 'text' => __( 'Show Text', 'indieweb-post-kinds' ), - 'hide' => __( 'Display Nothing', 'indieweb-post-kinds' ) - ) + 'hide' => __( 'Display Nothing', 'indieweb-post-kinds' ), + ), ) ); - if ( POST_KINDS_KSES ) { add_settings_field( 'contentelements', @@ -121,7 +124,9 @@ public static function admin_init() { array( 'Kind_Config', 'textbox_callback' ), 'iwt_options', 'iwt-content', - array( 'name' => 'kind_kses' ) + array( + 'name' => 'kind_kses', + ) ); } // Add Query Var to Admin @@ -129,7 +134,7 @@ public static function admin_init() { } - public static function query_var($vars) { + public static function query_var( $vars ) { $vars[] = 'kindurl'; return $vars; } @@ -161,7 +166,6 @@ public static function admin_menu() { * @access public */ public static function options_callback() { - esc_html_e( '', 'indieweb-post-kinds' ); } /** @@ -169,9 +173,9 @@ public static function options_callback() { * * @access public * @param array $args { - * Arguments. + * Arguments. * - * @type string $name Checkbox Name. + * @type string $name Checkbox Name. */ public static function checkbox_callback( array $args ) { $option = get_option( $args['name'] ); @@ -194,7 +198,7 @@ public static function textbox_callback( array $args ) { if ( is_array( $option ) ) { $option = print_r( $option, true ); } - echo " '; + echo " '; } /** @@ -208,7 +212,7 @@ public static function termcheck_callback() { $termslist = get_option( 'kind_termslist' ); foreach ( $terms as $key => $value ) { if ( $value['show'] ) { - echo "' . $value['singular_name'] . ' - ' . $value['description'] . '
'; + echo "' . $value['singular_name'] . ' - ' . $value['description'] . '
'; } } } @@ -226,7 +230,7 @@ public static function defaultkind_callback() { $defaultkind = get_option( 'kind_default' ); foreach ( $terms as $term ) { - echo '' . Kind_Taxonomy::get_kind_info( $term, 'singular_name' ) . '
'; + echo '' . Kind_Taxonomy::get_kind_info( $term, 'singular_name' ) . '
'; } } @@ -238,7 +242,7 @@ public static function defaultkind_callback() { public static function radio_callback( array $args ) { $display = get_option( 'kind_display' ); foreach ( $args['options'] as $key => $value ) { - echo '' . $value . '
'; + echo '' . $value . '
'; } } @@ -252,9 +256,9 @@ public static function radio_callback( array $args ) { public static function options_form() { Kind_Taxonomy::kind_defaultterms(); echo '
'; - echo '

' . esc_html__( 'Indieweb Post Kinds', 'Post kinds' ) . '

'; + echo '

' . esc_html__( 'Indieweb Post Kinds', 'indieweb-post-kinds' ) . '

'; echo '

'; - esc_html_e( 'Adds support for responding and interacting with other sites.', 'Post kinds' ); + esc_html_e( 'Adds support for responding and interacting with other sites.', 'indieweb-post-kinds' ); echo '


'; echo '
'; settings_fields( 'iwt_options' ); @@ -264,40 +268,44 @@ public static function options_form() { } public static function add_post_help_tab() { - get_current_screen()->add_help_tab( array( - 'id' => 'post_kind_help', - 'title' => __( 'Post Properties', 'indieweb-post-kinds' ), - 'content' => __(' -

The Post Properties tab represents the Microformats properties of a Post. For different kinds of posts, the different - fields mean something different. Example: Artist Name vs Author Name

- - - - - ', 'indieweb-post-kinds'), - ) ); + get_current_screen()->add_help_tab( + array( + 'id' => 'post_kind_help', + 'title' => __( 'Post Properties', 'indieweb-post-kinds' ), + 'content' => __( + ' +

The Post Properties tab represents the Microformats properties of a Post. For different kinds of posts, the different + fields mean something different. Example: Artist Name vs Author Name

+ + + + + ', 'indieweb-post-kinds' + ), + ) + ); } } // End Class -?> + diff --git a/includes/class-kind-meta.php b/includes/class-kind-meta.php index d527632..5233bd9 100644 --- a/includes/class-kind-meta.php +++ b/includes/class-kind-meta.php @@ -141,7 +141,7 @@ public static function sanitize_content( $value ) { return $value; } $allowed = wp_kses_allowed_html( 'post' ); - if ( 1 == get_option( 'kind_protection' ) ) { + if ( 1 === (int) get_option( 'kind_protection' ) ) { $allowed = json_decode( get_option( 'kind_kses' ), true ); } return wp_kses( $value , $allowed ); @@ -190,7 +190,7 @@ public function build_meta( $raw ) { * * @return string|array Either a string indicating the URL or an array of URLs. */ - public function get_url( ) { + public function get_url() { if ( ! isset( $this->meta ) ) { return false; } @@ -310,7 +310,7 @@ public function get_author() { * * array $author Data on Author. */ - public function set_author($author) { + public function set_author( $author ) { if ( ! isset( $author ) ) { return false; } @@ -326,7 +326,7 @@ public function set_author($author) { $this->meta['cite']['author'] = $author; } - public function set_cite($cite) { + public function set_cite( $cite ) { if ( ! $cite ) { return false; } @@ -342,7 +342,7 @@ public function set_cite($cite) { $this->meta['cite'] = $cite; } - public function build_time($date, $time, $offset) { + public function build_time( $date, $time, $offset ) { if ( empty( $date ) ) { $date = '0000-01-01'; } @@ -352,34 +352,38 @@ public function build_time($date, $time, $offset) { return $date . 'T' . $time . $offset; } - public static function DateIntervalToString(\DateInterval $interval) { + public static function date_interval_to_string( \DateInterval $interval ) { // Reading all non-zero date parts. - $date = array_filter(array( - 'Y' => $interval->y, - 'M' => $interval->m, - 'D' => $interval->d, - )); + $date = array_filter( + array( + 'Y' => $interval->y, + 'M' => $interval->m, + 'D' => $interval->d, + ) + ); // Reading all non-zero time parts. - $time = array_filter(array( - 'H' => $interval->h, - 'M' => $interval->i, - 'S' => $interval->s, - )); + $time = array_filter( + array( + 'H' => $interval->h, + 'M' => $interval->i, + 'S' => $interval->s, + ) + ); - $specString = 'P'; + $spec = 'P'; // Adding each part to the spec-string. foreach ( $date as $key => $value ) { - $specString .= $value . $key; + $spec .= $value . $key; } if ( count( $time ) > 0 ) { - $specString .= 'T'; + $spec .= 'T'; foreach ( $time as $key => $value ) { - $specString .= $value . $key; + $spec .= $value . $key; } } - return $specString; + return $spec; } public function get_duration() { @@ -398,14 +402,14 @@ public function calculate_duration( $start_string, $end_string ) { if ( ! is_string( $start_string ) || ! is_string( $end_string ) ) { return false; } - if ( $start_string == $end_string ) { + if ( $start_string === $end_string ) { return false; } $start = date_create_from_format( 'Y-m-d\TH:i:sP', $start_string ); $end = date_create_from_format( 'Y-m-d\TH:i:sP', $end_string ); - if ( ($start instanceof DateTime) && ($end instanceof DateTime) ) { + if ( ($start instanceof DateTime) && ($end instanceof DateTime) ) { $duration = $start->diff( $end ); - return self::DateIntervalToString( $duration ); + return self::date_interval_to_string( $duration ); } return false; } @@ -417,7 +421,7 @@ public function divide_time( $time_string ) { return; } $time['date'] = $datetime->format( 'Y-m-d' ); - if ( '0000-01-01' == $time['date'] ) { + if ( '0000-01-01' === $time['date'] ) { $time['date'] = ''; } $time['time'] = $datetime->format( 'H:i:s' ); @@ -435,7 +439,7 @@ public function get( $key ) { return ifset( $this->meta[ $key ] ); } - public function set( $key, $value) { + public function set( $key, $value ) { $this->meta[ $key ] = self::sanitize_text( $value ); } diff --git a/includes/class-kind-plugins.php b/includes/class-kind-plugins.php index c110154..67a05b5 100755 --- a/includes/class-kind-plugins.php +++ b/includes/class-kind-plugins.php @@ -21,19 +21,19 @@ public static function init() { } // Replaces need for Replacing the Entire Excerpt - public static function semantic_post_type($post_type, $post_id) { - return _x( 'this', 'indieweb-post-kinds' ) . ' ' . strtolower( get_post_kind( $post_id ) ); + public static function semantic_post_type( $post_type, $post_id ) { + return _x( 'this', 'direct article', 'indieweb-post-kinds' ) . ' ' . strtolower( get_post_kind( $post_id ) ); } // Replacement for the Semantic Linkbacks Comment Excerpt - public static function comment_text_excerpt($text, $comment = null, $args = array()) { + public static function comment_text_excerpt( $text, $comment = null, $args = array() ) { // only change text for pingbacks/trackbacks/webmentions if ( ! $comment || '' === $comment->comment_type || ! get_comment_meta( $comment->comment_ID, 'semantic_linkbacks_canonical', true ) ) { return $text; } // check comment type $comment_type = get_comment_meta( $comment->comment_ID, 'semantic_linkbacks_type', true ); - if ( ! $comment_type || ! in_array( $comment_type, array_keys( SemanticLinkbacksPlugin::get_comment_type_strings() ) ) ) { + if ( ! $comment_type || ! in_array( $comment_type, array_keys( SemanticLinkbacksPlugin::get_comment_type_strings() ), true ) ) { $comment_type = 'mention'; } $_kind = get_the_terms( $comment->comment_post_ID, 'kind' ); @@ -61,7 +61,7 @@ public static function comment_text_excerpt($text, $comment = null, $args = arra $url = get_comment_meta( $comment->comment_ID, 'semantic_linkbacks_source', true ); } // parse host - $host = parse_url( $url, PHP_URL_HOST ); + $host = wp_parse_url( $url, PHP_URL_HOST ); // strip leading www, if any $host = preg_replace( '/^www\./', '', $host ); // generate output @@ -105,17 +105,17 @@ public static function micropub_set_kind( $input, $wp_args ) { } // Video & audio come before photo, because either of these could contain a photo - if ( isset( $input['properties']['video'] ) || isset( $_FILES['video'] ) ) { + if ( isset( $input['properties']['video'] ) || isset( $_FILES['video'] ) ) { set_post_kind( $wp_args['ID'], 'video' ); return; } - if ( isset( $input['properties']['audio'] ) || isset( $_FILES['audio'] ) ) { + if ( isset( $input['properties']['audio'] ) || isset( $_FILES['audio'] ) ) { set_post_kind( $wp_args['ID'], 'audio' ); return; } - if ( isset( $input['properties']['photo'] ) || isset( $_FILES['photo'] ) ) { + if ( isset( $input['properties']['photo'] ) || isset( $_FILES['photo'] ) ) { set_post_kind( $wp_args['ID'], 'photo' ); return; } @@ -156,4 +156,4 @@ public static function post_formats( $input, $wp_args ) { } // End Class Kind_Plugins -?> + diff --git a/includes/class-kind-tabmeta.php b/includes/class-kind-tabmeta.php index 9289010..aa7be3f 100755 --- a/includes/class-kind-tabmeta.php +++ b/includes/class-kind-tabmeta.php @@ -58,7 +58,8 @@ public static function enqueue_admin_scripts() { // Provide a global object to our JS file containing our REST API endpoint, and API nonce // Nonce must be 'wp_rest' - wp_localize_script( 'kindmeta-response', 'rest_object', + wp_localize_script( + 'kindmeta-response', 'rest_object', array( 'api_nonce' => wp_create_nonce( 'wp_rest' ), 'api_url' => rest_url( '/link-preview/1.0/' ), @@ -87,8 +88,8 @@ public static function kind_get_timezones() { $seconds = $zone->getOffset( new DateTime( 'now' , $zone ) ); $o[] = self::tz_seconds_to_offset( $seconds ); } // exceptions must be catched, else a blank page - catch (Exception $e) { - // die("Exception : " . $e->getMessage() . '
'); + catch ( Exception $e ) { + die( 'Exception : ' . $e->getMessage() . '
' ); // what to do in catch ? , nothing just relax } } @@ -103,7 +104,7 @@ public static function kind_the_time( $prefix, $label, $time ) { if ( isset( $time['offset'] ) ) { $offset = $time['offset']; } - $string = '
'; + $string = '
'; $string .= ''; $string .= ''; $string .= self::select_offset( $prefix, $offset ); @@ -112,10 +113,10 @@ public static function kind_the_time( $prefix, $label, $time ) { public static function select_offset( $prefix, $select ) { $tzlist = self::kind_get_timezones(); - $string = ''; foreach ( $tzlist as $key => $value ) { $string .= '