From bc53103ac7e51d3e88a2b6aba5b1406c0f062eab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20HULARD?= Date: Sat, 6 May 2017 18:08:37 +0200 Subject: [PATCH] Apply code style fix regarding WordPress rules. --- index.php | 2 +- options.php | 36 +++++++++++++++++++++++++++------ phpcs.xml | 11 +++++++++++ wpmautic.php | 56 ++++++++++++++++++++++++++++++++++++++++------------ 4 files changed, 85 insertions(+), 20 deletions(-) diff --git a/index.php b/index.php index eea59b9..6220032 100644 --- a/index.php +++ b/index.php @@ -1,2 +1,2 @@

WP Mautic

Enable Base URL for Mautic Integration.

- - + +

Shortcode Examples:

@@ -44,22 +52,38 @@ function wpmautic_options_page() { "; + ?> + + + + + + */index.php + + + */index.php + + + */wpmautic.php + diff --git a/wpmautic.php b/wpmautic.php index 15c3e46..88575fd 100644 --- a/wpmautic.php +++ b/wpmautic.php @@ -7,18 +7,20 @@ * Author: Mautic community * Author URI: http://mautic.org * License: GPL2 + * + * @package wpmautic */ // Prevent direct access to this file. if ( ! defined( 'ABSPATH' ) ) { header( 'HTTP/1.0 403 Forbidden' ); echo 'This file should not be accessed directly!'; - exit; // Exit if accessed directly + exit; // Exit if accessed directly. } -// Store plugin directory +// Store plugin directory. define( 'VPMAUTIC_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); -// Store plugin main file path +// Store plugin main file path. define( 'VPMAUTIC_PLUGIN_FILE', __FILE__ ); add_action( 'admin_menu', 'wpmautic_settings' ); @@ -26,6 +28,9 @@ add_shortcode( 'mautic', 'wpmautic_shortcode' ); add_shortcode( 'mauticform', 'wpmautic_form_shortcode' ); +/** + * Declare option page + */ function wpmautic_settings() { include_once( dirname( __FILE__ ) . '/options.php' ); add_options_page( 'WP Mautic Settings', 'WPMautic', 'manage_options', 'wpmautic', 'wpmautic_options_page' ); @@ -33,11 +38,16 @@ function wpmautic_settings() { /** * Settings Link in the ``Installed Plugins`` page + * + * @param array $links array of plugin action links. + * @param string $file Path to the plugin file relative to the plugins directory. + * + * @return array */ function wpmautic_plugin_actions( $links, $file ) { - if ( $file == plugin_basename( VPMAUTIC_PLUGIN_FILE ) && function_exists( 'admin_url' ) ) { + if ( plugin_basename( VPMAUTIC_PLUGIN_FILE ) === $file && function_exists( 'admin_url' ) ) { $settings_link = '' . __( 'Settings' ) . ''; - // Add the settings link before other links + // Add the settings link before other links. array_unshift( $links, $settings_link ); } return $links; @@ -51,7 +61,7 @@ function wpmautic_function() { $options = get_option( 'wpmautic_options' ); $base_url = trim( $options['base_url'], " \t\n\r\0\x0B/" ); - $mauticTrackingJS = << (function(w,d,t,u,n,a,m){w['MauticTrackingObject']=n; w[n]=w[n]||function(){(w[n].q=w[n].q||[]).push(arguments)},a=d.createElement(t), @@ -60,9 +70,9 @@ function wpmautic_function() { mt('send', 'pageview'); -JS; +HTML; - echo $mauticTrackingJS; + echo esc_js( $javascript ); } /** @@ -74,8 +84,8 @@ function wpmautic_function() { * example: [mautic type="content" slot="slot_name"]Default Content[/mautic] * example: [mautic type="video" gate-time="15" form-id="1" src="https://www.youtube.com/watch?v=QT6169rdMdk"] * - * @param $atts - * @param null $content + * @param array $atts Shortcode attributes. + * @param string|null $content Default content to be displayed. * * @return string */ @@ -107,7 +117,8 @@ function wpmautic_shortcode( $atts, $content = null ) { * Handle mauticform shortcode * example: [mauticform id="1"] * - * @param array $atts + * @param array $atts Shortcode attributes. + * * @return string */ function wpmautic_form_shortcode( $atts ) { @@ -124,6 +135,14 @@ function wpmautic_form_shortcode( $atts ) { return ''; } +/** + * Dynamic content shortcode handling + * + * @param array $atts Shortcode attributes. + * @param string|null $content Default content to be displayed. + * + * @return string + */ function wpmautic_dwc_shortcode( $atts, $content = null ) { $options = get_option( 'wpmautic_options' ); $base_url = trim( $options['base_url'], " \t\n\r\0\x0B/" ); @@ -134,6 +153,13 @@ function wpmautic_dwc_shortcode( $atts, $content = null ) { return '
' . $content . '
'; } +/** + * Video shortcode handling + * + * @param array $atts Shortcode attributes. + * + * @return string + */ function wpmautic_video_shortcode( $atts ) { $video_type = ''; $atts = shortcode_atts(array( @@ -176,8 +202,9 @@ function wpmautic_video_shortcode( $atts ) { * Creates a nicely formatted and more specific title element text * for output in head of document, based on current view. * - * @param string $title Default title text for current view. - * @param string $sep Optional separator. + * @param string $title Default title text for current view. + * @param string $sep Optional separator. + * * @return string Filtered title. */ function wpmautic_wp_title( $title = '', $sep = '' ) { @@ -192,6 +219,9 @@ function wpmautic_wp_title( $title = '', $sep = '' ) { // Add a page number if necessary. if ( $paged >= 2 || $page >= 2 ) { + /* + * translators: Pagination number + */ $title = "$title $sep " . sprintf( __( 'Page %s', 'twentytwelve' ), max( $paged, $page ) ); }