diff --git a/classes/class-sailthru-content.php b/classes/class-sailthru-content.php index b45123f..7d395b6 100644 --- a/classes/class-sailthru-content.php +++ b/classes/class-sailthru-content.php @@ -4,7 +4,7 @@ class Sailthru_Content_Settings { public function __construct() { - // make sure the priority is above the default of 10, the meta boxes are saved first. + // make sure the priority is above the default of 10, the meta boxes are saved first. add_action( 'admin_menu', array( $this, 'add_admin_menu' ), 11 ); add_action( 'admin_init', array( $this, 'init_settings' ), 11 ); add_action( 'save_post', array( $this, 'sailthru_save_post' ), 11, 3 ); @@ -51,7 +51,7 @@ public function init_settings() { // Only show these fields if the status has been enabled if ( isset ( $options['sailthru_content_api_status'] ) && 'true' === $options['sailthru_content_api_status'] ) { - + add_settings_field( 'sailthru_spider_status', __( 'Spider', 'text_domain' ), @@ -116,7 +116,7 @@ public function page_layout() { } // Admin Page Layout - echo '
' . "\n"; + echo '
' . "\n"; echo '

Sailthru for WordPress

' . "\n"; echo '
' . "\n"; @@ -182,11 +182,11 @@ function render_sailthru_content_post_types_field() { $value = isset( $options['sailthru_content_post_types'] ) ? $options['sailthru_content_post_types'] : ''; if ( false != $options ) { - + $post_type_args = ['public' => true]; $post_types = get_post_types( $post_type_args, 'names'); - - // Always remove the attachment post type, we never need this. + + // Always remove the attachment post type, we never need this. unset ($post_types['attachment']); echo '

' . esc_attr__( 'Choose which type of post types should be synced to Sailthru', 'text_domain' ) . '

'; @@ -197,7 +197,7 @@ function render_sailthru_content_post_types_field() { echo ' ' . esc_attr__( ucwords ( $type ) , 'text_domain' ) . '
'; } - } + } } @@ -252,10 +252,10 @@ function render_sailthru_taxonomy_tag_options_field() { $value = isset( $options['sailthru_taxonomy_tag_options'] ) ? $options['sailthru_taxonomy_tag_options'] : array(); foreach ($taxonomies as $tag) { - + echo ' ' . esc_attr__( $tag, 'text_domain' ) . '
'; } - + } @@ -317,17 +317,17 @@ function generate_payload( $post, $post_id ) { $data['images']['thumb']['url'] = $post_thumbnail; } - // Add any galleries from the post to the images. + // Add any galleries from the post to the images. $data['images']['galleries'] = get_post_galleries_images( $post ); $data['tags'] = $this->generate_tags( $post->ID); - // Apply any filters to the tags. - $data['tags'] = apply_filters( 'sailthru_horizon_meta_tags', ['sailthru.tags' => $data['tags'] ] ) ; + // Apply any filters to the tags. + $data['tags'] = apply_filters( 'sailthru_horizon_meta_tags', ['sailthru.tags' => $data['tags'] ] ) ; - // Check if the filter has returned sailthru.tags and convert to string. + // Check if the filter has returned sailthru.tags and convert to string. if ( is_array( $data['tags'] ) && isset ( $data['tags']['sailthru.tags'] ) ) { - $data['tags'] = $data['tags']['sailthru.tags']; + $data['tags'] = $data['tags']['sailthru.tags']; } $post_expiration = get_post_meta( $post->ID, 'sailthru_post_expiration', true ); @@ -341,7 +341,7 @@ function generate_payload( $post, $post_id ) { // Add the vars $data['vars'] = $this->generate_vars( $post->ID, $post ); - + return $data; } @@ -394,7 +394,7 @@ function generate_meta_tags() { $post_title = get_the_title(); $horizon_tags['sailthru.title'] = esc_attr( $post_title ); - // Get the tags. + // Get the tags. $content = new Sailthru_Content_Settings; $post_tags = $content->generate_tags( $post->ID); @@ -457,26 +457,26 @@ function generate_meta_tags() { } /** - * Generates the output of the interest tags for both the Content API and the meta tags. + * Generates the output of the interest tags for both the Content API and the meta tags. * * @param integer $post_id */ function generate_tags( $post_id ) { - + $options = get_option( 'sailthru_content_settings' ); $post_tags = get_post_meta( $post_id, 'sailthru_meta_tags', true ); - // Add WordPress tags if option set. + // Add WordPress tags if option set. if ( isset( $options['sailthru_interest_tag_options'] ) && in_array( 'wordpress_tags',$options['sailthru_interest_tag_options'] ) ) { - + $wp_tags = get_the_tags(); if ( $wp_tags ) { $post_tags .= ',' .esc_attr( implode( ',', wp_list_pluck( $wp_tags, 'name' ) ) ); } } - // Add WordPress categories if option set. + // Add WordPress categories if option set. if ( isset( $options['sailthru_interest_tag_options'] ) && in_array( 'wordpress_categories', $options['sailthru_interest_tag_options'] ) ) { $post_categories = get_the_category( $post->ID ); foreach ( $post_categories as $post_category ) { @@ -484,14 +484,14 @@ function generate_tags( $post_id ) { } } - // Add WordPress taxonomies if option set. + // Add WordPress taxonomies if option set. if ( !empty( $options['sailthru_taxonomy_tag_options'] ) ) { $terms = wp_get_post_terms( $post_id, $options['sailthru_taxonomy_tag_options'] ); $post_tags .= ',' .esc_attr( implode( ',', wp_list_pluck( $terms, 'name' ) ) ); } - // check if there's any global tags needing added. + // check if there's any global tags needing added. if ( ! empty($options['sailthru_content_interest_tags'] ) ) { $post_tags .= ',' . $options['sailthru_content_interest_tags']; } @@ -500,13 +500,13 @@ function generate_tags( $post_id ) { } /** - * Generates the output of the interest tags for both the Content API and the meta tags. + * Generates the output of the interest tags for both the Content API and the meta tags. * * @param integer $post_id */ function generate_vars( $post_id, $post ) { - + $vars = [ 'post_type' => $post->post_type, 'id' => $post->ID, @@ -518,16 +518,16 @@ function generate_vars( $post_id, $post ) { $field_names = array_keys( array_merge( $custom_fields, $vars ) ); // always exclude these vars - $exclude_fields = array( '_edit_lock', - '_edit_last', - '_encloseme', - '_pingme', - 'sailthru_meta_tags', - 'sailthru_post_expiration', - 'sailthru_sailthru_tags_extra_data' + $exclude_fields = array( '_edit_lock', + '_edit_last', + '_encloseme', + '_pingme', + 'sailthru_meta_tags', + 'sailthru_post_expiration', + 'sailthru_sailthru_tags_extra_data' ); - // Set vars from the custom fields. + // Set vars from the custom fields. foreach ( $custom_fields as $key => $val ) { if ( ! in_array( $key, $exclude_fields, true ) ) { @@ -542,7 +542,7 @@ function generate_vars( $post_id, $post ) { } /** - * Generates vars from the whitelisted vars and filters + * Generates vars from the whitelisted vars and filters * * @param array $vars */ @@ -551,13 +551,13 @@ function whitelist_vars( $vars ) { $options = get_option( 'sailthru_content_settings' ); if (! empty($options['sailthru_content_vars'] ) ) { - - // Get the Whitelisted vars from the settings screen. + + // Get the Whitelisted vars from the settings screen. $whitelist = explode(', ', $options['sailthru_content_vars']); $whitelist = apply_filters( 'sailthru_content_whitelist_vars', $whitelist); foreach ($vars as $key => $val) { - + if ( !in_array($key, $whitelist) ) { unset( $vars[$key] ); } @@ -580,7 +580,7 @@ function whitelist_vars( $vars ) { function sailthru_save_post( $post_id, $post, $update ) { - // Get the content options to see if we want to fire the API. + // Get the content options to see if we want to fire the API. $options = get_option( 'sailthru_content_settings' ); // Check to see if Content API is disabled in the UI @@ -588,7 +588,7 @@ function sailthru_save_post( $post_id, $post, $update ) { return; } - // See if a filter has disabled the content API, this may be done to override a specific use case. + // See if a filter has disabled the content API, this may be done to override a specific use case. if ( false === apply_filters( 'sailthru_content_api_enable', true ) ) { return; } @@ -604,7 +604,7 @@ function sailthru_save_post( $post_id, $post, $update ) { $api_secret = $sailthru['sailthru_api_secret']; $client = new WP_Sailthru_Client( $api_key, $api_secret ); try { - + if ( $client ) { $data = $this->generate_payload($post, $post_id); // Make the API call to Sailthru diff --git a/js/admin.js b/js/admin.js index b44b21d..3b40315 100755 --- a/js/admin.js +++ b/js/admin.js @@ -38,8 +38,8 @@ // datepicker for meta box // but since Datepicker causes a jQuery conflict, wrap it // and prevent from initializing unless necessary - if ($('.datepicker').length) { - $('.datepicker').datepicker({ + if ($('.datepicker', 'sailthru-wrap').length) { + $('.datepicker', 'sailthru-wrap').datepicker({ dateFormat: 'yy-mm-dd' }); } @@ -47,7 +47,7 @@ // custom form fields - $('.selection').parent().parent().hide(); + $('.selection', '.sailthru-wrap').parent().parent().hide(); $('#type').closest('table').find("tr").last().hide(); // hide hidden field $("#sailthru_customfield_hidden_value").closest('tr').hide(); @@ -70,14 +70,14 @@ if ($(this).attr('value') == 'select' || $(this).attr('value') == 'radio' || $(this).attr('value') == 'checkbox') { $(this).closest('table').find("tr").last().show(); - $('#add_value').show(); + $('#add_value', 'sailthru-wrap').show(); $("input[name*=sailthru_customfield_value1]").show(); - $('.selection').parent().parent().show(); - $('#add_value').show(); + $('.selection', 'sailthru-wrap').parent().parent().show(); + $('#add_value', 'sailthru-wrap').show(); $("input[name*=sailthru_customfield_value1]").show(); if ($(this).attr('value') == 'hidden') { - $('#add_value').hide(); + $('#add_value', 'sailthru-wrap').hide(); $("input[name*=sailthru_customfield_value1]").hide(); $("input[name*=sailthru_customfield_value1]").parent().parent().find('th').html('Field Value'); } @@ -87,11 +87,10 @@ } })); - $('#add_value').on("click", (function(e) { + $('#add_value', 'sailthru-wrap').on("click", (function(e) { e.preventDefault(); var new_val = parseInt($('#value_amount').attr('value'), 10); new_val = new_val + 1; - var second_val = new_val + 1; $('#sailthru_value_fields_block').append('
'); $('#value_amount').attr('value', parseInt(new_val, 10)); })); @@ -118,12 +117,12 @@ $("#sailthru_setup_email_template").parents('tr').addClass('grayBorder'); // datepickerfor meta box - $('.datepicker').datepicker({ + $('.datepicker', 'sailthru-wrap').datepicker({ dateFormat: 'yy-mm-dd' }); - $("#sortable").disableSelection(); - var sort = $("#sortable").sortable({ + $("#sortable", 'sailthru-wrap').disableSelection(); + var sort = $("#sortable", 'sailthru-wrap').sortable({ axis: 'y', stop: function(event, ui) { var data = sort.sortable("serialize"); @@ -143,4 +142,4 @@ }); -}(jQuery)); \ No newline at end of file +}(jQuery)); diff --git a/views/admin.functions.subscribe.options.php b/views/admin.functions.subscribe.options.php index d80c9d0..c6bdfc3 100644 --- a/views/admin.functions.subscribe.options.php +++ b/views/admin.functions.subscribe.options.php @@ -82,7 +82,7 @@ function sailthru_forms_callback( $args ) { ** Custom and Extra Sections should be in a first column. ** Begin the column here. It ends in delete_field() */ - echo '
'; + echo '
'; $customfields = get_option( 'sailthru_forms_options' ); $key = get_option( 'sailthru_forms_key' ); @@ -202,7 +202,7 @@ function sailthru_success_field( $args ) { echo '

'; echo '

Use the field above to update the message that the user sees after subscribing

'; - /* ends the wrapper */ + /* ends the wrapper */ echo '
'; echo '
'; @@ -607,7 +607,7 @@ function sailthru_forms_handler( $input ) { $values = rtrim( $values, ',' ); $output[ $new_key ]['sailthru_customfield_value'] = $values; } - + if ( 'hidden' === $input['sailthru_customfield_type'] ) { $output[ $new_key ]['sailthru_customfield_value'] = sanitize_text_field( $input['sailthru_customfield_hidden_value'] ); } diff --git a/views/admin.php b/views/admin.php index e5c635d..b93b180 100644 --- a/views/admin.php +++ b/views/admin.php @@ -1,5 +1,5 @@ -
+