PHP formatting fixes
This commit is contained in:
parent
054ceef45e
commit
6a5c99e483
|
@ -28,7 +28,7 @@
|
|||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@ -36,8 +36,8 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
* The Plugin
|
||||
*/
|
||||
|
||||
if ( !class_exists('CognitoFormsPlugin') ) {
|
||||
require_once dirname(__FILE__) . '/api.php';
|
||||
if ( !class_exists( 'CognitoFormsPlugin' ) ) {
|
||||
require_once dirname( __FILE__ ) . '/api.php';
|
||||
|
||||
class CognitoFormsPlugin {
|
||||
// Initialization actions
|
||||
|
@ -49,26 +49,26 @@ if ( !class_exists('CognitoFormsPlugin') ) {
|
|||
|
||||
// Supported shortcodes
|
||||
private static $shortcodes = array(
|
||||
'CognitoForms' => 'render_shortcode',
|
||||
'cognitoforms' => 'render_shortcode'
|
||||
'CognitoForms' => 'render_cognito_shortcode',
|
||||
'cognitoforms' => 'render_cognito_shortcode'
|
||||
);
|
||||
|
||||
// Registers plug-in actions
|
||||
private function addActions($actions) {
|
||||
foreach($actions as $action)
|
||||
add_action($action, array($this, $action));
|
||||
private function add_actions( $actions ) {
|
||||
foreach ( $actions as $action )
|
||||
add_action( $action, array( $this, $action ) );
|
||||
}
|
||||
|
||||
// Registers plug-in filters
|
||||
private function addFilters($filters) {
|
||||
foreach($filters as $filter)
|
||||
add_filter($filter, array($this, $filter));
|
||||
private function add_filters( $filters ) {
|
||||
foreach ( $filters as $filter )
|
||||
add_filter( $filter, array( $this, $filter ) );
|
||||
}
|
||||
|
||||
// Registers shortcodes
|
||||
private function addShortcodes($shortcodes) {
|
||||
foreach($shortcodes as $tag => $func)
|
||||
add_shortcode($tag, array($this, $func));
|
||||
private function add_shortcodes( $shortcodes ) {
|
||||
foreach ( $shortcodes as $tag => $func )
|
||||
add_shortcode( $tag, array( $this, $func ) );
|
||||
}
|
||||
|
||||
// Checks if an option exists in the database
|
||||
|
@ -88,8 +88,8 @@ if ( !class_exists('CognitoFormsPlugin') ) {
|
|||
|
||||
// Entrypoint
|
||||
public function __construct() {
|
||||
$this->addActions(self::$actions);
|
||||
$this->addShortcodes(self::$shortcodes);
|
||||
$this->add_actions( self::$actions );
|
||||
$this->add_shortcodes( self::$shortcodes );
|
||||
}
|
||||
|
||||
public function init() {
|
||||
|
@ -104,7 +104,7 @@ if ( !class_exists('CognitoFormsPlugin') ) {
|
|||
if( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) )
|
||||
return;
|
||||
|
||||
register_setting('cognito_plugin', 'cognito_public_key');
|
||||
add_option( 'cognito_public_key' );
|
||||
|
||||
// Remove old API keys from the database
|
||||
$this->remove_options( array(
|
||||
|
@ -115,7 +115,7 @@ if ( !class_exists('CognitoFormsPlugin') ) {
|
|||
|
||||
// If the flag to delete options was passed in, delete them
|
||||
if ( isset( $_GET['cog_clear'] ) && $_GET['cog_clear'] == '1' ) {
|
||||
delete_option('cognito_public_key');
|
||||
delete_option( 'cognito_public_key' );
|
||||
}
|
||||
|
||||
// Initialize TinyMCE Plugin
|
||||
|
@ -124,7 +124,7 @@ if ( !class_exists('CognitoFormsPlugin') ) {
|
|||
|
||||
// Initialize block
|
||||
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
|
||||
wp_register_style(
|
||||
|
@ -164,22 +164,22 @@ if ( !class_exists('CognitoFormsPlugin') ) {
|
|||
|
||||
// Initialize classic editor (TinyMCE)
|
||||
public function tinymce_init() {
|
||||
if(get_user_option('rich_editing') == 'true') {
|
||||
$this->addFilters( array(
|
||||
'mce_buttons',
|
||||
'mce_external_plugins'
|
||||
if ( get_user_option( 'rich_editing' ) == 'true' ) {
|
||||
$this->add_filters( array(
|
||||
'tinymce_buttons',
|
||||
'tinymce_external_plugins'
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
// Set up TinyMCE buttons
|
||||
public function mce_buttons( $buttons ) {
|
||||
public function tinymce_buttons( $buttons ) {
|
||||
array_push($buttons, '|', 'cognito');
|
||||
return $buttons;
|
||||
}
|
||||
|
||||
// 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__ );
|
||||
return $plugin_array;
|
||||
}
|
||||
|
@ -193,12 +193,12 @@ if ( !class_exists('CognitoFormsPlugin') ) {
|
|||
}
|
||||
|
||||
// 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)
|
||||
$key = empty($atts['key']) ? get_option('cognito_public_key') : $atts['key'];
|
||||
if (empty($atts['id']) || empty($key)) return '';
|
||||
$key = empty( $atts['key'] ) ? get_option( 'cognito_public_key' ) : $atts['key'];
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue