PHP formatting fixes
This commit is contained in:
parent
054ceef45e
commit
6a5c99e483
|
@ -28,7 +28,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Exit if accessed directly.
|
// Exit if accessed directly.
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( !defined( 'ABSPATH' ) ) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||||
* The Plugin
|
* The Plugin
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( !class_exists('CognitoFormsPlugin') ) {
|
if ( !class_exists( 'CognitoFormsPlugin' ) ) {
|
||||||
require_once dirname(__FILE__) . '/api.php';
|
require_once dirname( __FILE__ ) . '/api.php';
|
||||||
|
|
||||||
class CognitoFormsPlugin {
|
class CognitoFormsPlugin {
|
||||||
// Initialization actions
|
// Initialization actions
|
||||||
|
@ -49,26 +49,26 @@ if ( !class_exists('CognitoFormsPlugin') ) {
|
||||||
|
|
||||||
// Supported shortcodes
|
// Supported shortcodes
|
||||||
private static $shortcodes = array(
|
private static $shortcodes = array(
|
||||||
'CognitoForms' => 'render_shortcode',
|
'CognitoForms' => 'render_cognito_shortcode',
|
||||||
'cognitoforms' => 'render_shortcode'
|
'cognitoforms' => 'render_cognito_shortcode'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Registers plug-in actions
|
// Registers plug-in actions
|
||||||
private function addActions($actions) {
|
private function add_actions( $actions ) {
|
||||||
foreach($actions as $action)
|
foreach ( $actions as $action )
|
||||||
add_action($action, array($this, $action));
|
add_action( $action, array( $this, $action ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Registers plug-in filters
|
// Registers plug-in filters
|
||||||
private function addFilters($filters) {
|
private function add_filters( $filters ) {
|
||||||
foreach($filters as $filter)
|
foreach ( $filters as $filter )
|
||||||
add_filter($filter, array($this, $filter));
|
add_filter( $filter, array( $this, $filter ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Registers shortcodes
|
// Registers shortcodes
|
||||||
private function addShortcodes($shortcodes) {
|
private function add_shortcodes( $shortcodes ) {
|
||||||
foreach($shortcodes as $tag => $func)
|
foreach ( $shortcodes as $tag => $func )
|
||||||
add_shortcode($tag, array($this, $func));
|
add_shortcode( $tag, array( $this, $func ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if an option exists in the database
|
// Checks if an option exists in the database
|
||||||
|
@ -88,8 +88,8 @@ if ( !class_exists('CognitoFormsPlugin') ) {
|
||||||
|
|
||||||
// Entrypoint
|
// Entrypoint
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->addActions(self::$actions);
|
$this->add_actions( self::$actions );
|
||||||
$this->addShortcodes(self::$shortcodes);
|
$this->add_shortcodes( self::$shortcodes );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function init() {
|
public function init() {
|
||||||
|
@ -104,7 +104,7 @@ if ( !class_exists('CognitoFormsPlugin') ) {
|
||||||
if( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) )
|
if( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
register_setting('cognito_plugin', 'cognito_public_key');
|
add_option( 'cognito_public_key' );
|
||||||
|
|
||||||
// Remove old API keys from the database
|
// Remove old API keys from the database
|
||||||
$this->remove_options( array(
|
$this->remove_options( array(
|
||||||
|
@ -115,7 +115,7 @@ if ( !class_exists('CognitoFormsPlugin') ) {
|
||||||
|
|
||||||
// If the flag to delete options was passed in, delete them
|
// If the flag to delete options was passed in, delete them
|
||||||
if ( isset( $_GET['cog_clear'] ) && $_GET['cog_clear'] == '1' ) {
|
if ( isset( $_GET['cog_clear'] ) && $_GET['cog_clear'] == '1' ) {
|
||||||
delete_option('cognito_public_key');
|
delete_option( 'cognito_public_key' );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize TinyMCE Plugin
|
// Initialize TinyMCE Plugin
|
||||||
|
@ -124,7 +124,7 @@ if ( !class_exists('CognitoFormsPlugin') ) {
|
||||||
|
|
||||||
// Initialize block
|
// Initialize block
|
||||||
public function block_init() {
|
public function block_init() {
|
||||||
$asset_file = include( plugin_dir_path( __FILE__ ) . 'dist/index.asset.php');
|
$asset_file = include( plugin_dir_path( __FILE__ ) . 'dist/index.asset.php' );
|
||||||
|
|
||||||
// Register global block styles
|
// Register global block styles
|
||||||
wp_register_style(
|
wp_register_style(
|
||||||
|
@ -164,22 +164,22 @@ if ( !class_exists('CognitoFormsPlugin') ) {
|
||||||
|
|
||||||
// Initialize classic editor (TinyMCE)
|
// Initialize classic editor (TinyMCE)
|
||||||
public function tinymce_init() {
|
public function tinymce_init() {
|
||||||
if(get_user_option('rich_editing') == 'true') {
|
if ( get_user_option( 'rich_editing' ) == 'true' ) {
|
||||||
$this->addFilters( array(
|
$this->add_filters( array(
|
||||||
'mce_buttons',
|
'tinymce_buttons',
|
||||||
'mce_external_plugins'
|
'tinymce_external_plugins'
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up TinyMCE buttons
|
// Set up TinyMCE buttons
|
||||||
public function mce_buttons( $buttons ) {
|
public function tinymce_buttons( $buttons ) {
|
||||||
array_push($buttons, '|', 'cognito');
|
array_push($buttons, '|', 'cognito');
|
||||||
return $buttons;
|
return $buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up TinyMCE plug-in
|
// Set up TinyMCE plug-in
|
||||||
public function mce_external_plugins( $plugin_array ) {
|
public function tinymce_external_plugins( $plugin_array ) {
|
||||||
$plugin_array['cognito_mce_plugin'] = plugins_url( '/tinymce/plugin.js', __FILE__ );
|
$plugin_array['cognito_mce_plugin'] = plugins_url( '/tinymce/plugin.js', __FILE__ );
|
||||||
return $plugin_array;
|
return $plugin_array;
|
||||||
}
|
}
|
||||||
|
@ -193,12 +193,12 @@ if ( !class_exists('CognitoFormsPlugin') ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when a 'CognitoForms' shortcode is encountered, renders form embed script
|
// Called when a 'CognitoForms' shortcode is encountered, renders form embed script
|
||||||
public function render_shortcode($atts, $content = null, $code = '') {
|
public function render_cognito_shortcode( $atts, $content = null, $code = '' ) {
|
||||||
// Default to key setting, unless overridden in shortcode (allows for modules from multiple orgs)
|
// Default to key setting, unless overridden in shortcode (allows for modules from multiple orgs)
|
||||||
$key = empty($atts['key']) ? get_option('cognito_public_key') : $atts['key'];
|
$key = empty( $atts['key'] ) ? get_option( 'cognito_public_key' ) : $atts['key'];
|
||||||
if (empty($atts['id']) || empty($key)) return '';
|
if ( empty( $atts['id'] ) || empty( $key ) ) return '';
|
||||||
|
|
||||||
return CognitoAPI::get_form_embed_script($key, $atts['id']);
|
return CognitoAPI::get_form_embed_script( $key, $atts['id'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Entrypoint for Cognito Forms access
|
// Entrypoint for Cognito Forms access
|
||||||
|
|
Loading…
Reference in New Issue