예제 #1
1
 /**
  * Index a post under a given site index or the global index ($site_id = 0)
  *
  * @param array $post
  * @param bool $blocking
  * @since 0.1.0
  * @return array|bool|mixed
  */
 public function index_post($post, $blocking = true)
 {
     /**
      * Filter post prior to indexing
      *
      * Allows for last minute indexing of post information.
      *
      * @since 1.7
      *
      * @param         array Array of post information to index.
      */
     $post = apply_filters('ep_pre_index_post', $post);
     $index = trailingslashit(ep_get_index_name());
     $path = $index . 'post/' . $post['post_id'];
     if (function_exists('wp_json_encode')) {
         $encoded_post = wp_json_encode($post);
     } else {
         $encoded_post = json_encode($post);
     }
     $request_args = array('body' => $encoded_post, 'method' => 'PUT', 'timeout' => 15, 'blocking' => $blocking);
     $request = ep_remote_request($path, apply_filters('ep_index_post_request_args', $request_args, $post));
     do_action('ep_index_post_retrieve_raw_response', $request, $post, $path);
     if (!is_wp_error($request)) {
         $response_body = wp_remote_retrieve_body($request);
         return json_decode($response_body);
     }
     return false;
 }
 public function _mock_subscribe_response($url, $args)
 {
     $metadata = json_decode($args['body']);
     $register = array('client_id' => '123456789', 'client_secret' => '987654321', 'client_id_issued_at' => time(), 'client_secret_expires_at' => 0);
     $body = array('register' => array_merge($register, (array) $metadata), 'authorize' => array('access_token' => 'abcdef', 'token_type' => 'bearer', 'expires_in' => 120, 'scope' => 'read', 'refresh_token' => 'zyxwvu', 'user_id' => 1));
     return array('body' => wp_json_encode($body), 'headers' => array('content-type' => 'application/json'), 'response' => array('code' => 201));
 }
 function do_json_encode($data)
 {
     $json_options = 0;
     if (defined('JSON_HEX_TAG')) {
         $json_options += JSON_HEX_TAG;
     }
     if (defined('JSON_HEX_APOS')) {
         $json_options += JSON_HEX_APOS;
     }
     if (defined('JSON_HEX_QUOT')) {
         $json_options += JSON_HEX_QUOT;
     }
     if (defined('JSON_HEX_AMP')) {
         $json_options += JSON_HEX_AMP;
     }
     if (defined('JSON_UNESCAPED_UNICODE')) {
         $json_options += JSON_UNESCAPED_UNICODE;
     }
     if (version_compare($this->sitepress->get_wp_api()->phpversion(), '5.3.0', '<')) {
         $json_data = wp_json_encode($data);
     } else {
         $json_data = wp_json_encode($data, $json_options);
     }
     return $json_data;
 }
 /**
  * Retrieves information about the user who is currently logged into the site.
  *
  * This function is intended to be called via the client-side of the public-facing
  * side of the site.
  *
  * @since    1.0.0
  */
 public function get_current_user_info()
 {
     $user_id = get_current_user_id();
     if ($this->user_is_logged_in($user_id) && $this->user_exists($user_id)) {
         wp_send_json_success(wp_json_encode(get_user_by('id', $user_id)));
     }
 }
예제 #5
0
 /**
  * Decide whether to send tracking data or not.
  *
  * @param bool $override
  */
 public static function send_tracking_data($override = false)
 {
     // Don't trigger this on AJAX Requests
     if (defined('DOING_AJAX') && DOING_AJAX) {
         return;
     }
     if (!self::is_allow_track()) {
         return;
     }
     if (!apply_filters('elementor/tracker/send_override', $override)) {
         // Send a maximum of once per week by default.
         $last_send = self::_get_last_send_time();
         if ($last_send && $last_send > apply_filters('elementor/tracker/last_send_interval', strtotime('-1 week'))) {
             return;
         }
     } else {
         // Make sure there is at least a 1 hour delay between override sends, we dont want duplicate calls due to double clicking links.
         $last_send = self::_get_last_send_time();
         if ($last_send && $last_send > strtotime('-1 hours')) {
             return;
         }
     }
     // Update time first before sending to ensure it is set
     update_option('elementor_tracker_last_send', time());
     // Send here..
     $params = ['system' => self::_get_system_reports_data(), 'site_lang' => get_bloginfo('language'), 'email' => get_option('admin_email'), 'usages' => ['posts' => self::_get_posts_usage(), 'library' => self::_get_library_usage()]];
     add_filter('https_ssl_verify', '__return_false');
     $response = wp_safe_remote_post(self::$_api_url, ['timeout' => 25, 'blocking' => false, 'body' => ['data' => wp_json_encode($params)]]);
 }
 /**
  * Retrieve the current event queue
  *
  * @subcommand get-queue
  */
 public function get_queue($args, $assoc_args)
 {
     // Build and make request
     $queue_request = new \WP_REST_Request('POST', '/' . \Automattic\WP\Cron_Control\REST_API::API_NAMESPACE . '/' . \Automattic\WP\Cron_Control\REST_API::ENDPOINT_LIST);
     $queue_request->add_header('Content-Type', 'application/json');
     $queue_request->set_body(wp_json_encode(array('secret' => \WP_CRON_CONTROL_SECRET)));
     $queue_request = rest_do_request($queue_request);
     // Oh well
     if ($queue_request->is_error()) {
         \WP_CLI::error($queue_request->as_error()->get_error_message());
     }
     // Get the decoded JSON object returned by the API
     $queue_response = $queue_request->get_data();
     // No events, nothing more to do
     if (empty($queue_response['events'])) {
         \WP_CLI::warning(__('No events in the current queue', 'automattic-cron-control'));
         return;
     }
     // Prepare items for display
     $events_for_display = $this->format_events($queue_response['events']);
     $total_events_to_display = count($events_for_display);
     \WP_CLI::line(sprintf(_n('Displaying one event', 'Displaying %s events', $total_events_to_display, 'automattic-cron-control'), number_format_i18n($total_events_to_display)));
     // And reformat
     $format = 'table';
     if (isset($assoc_args['format'])) {
         if ('ids' === $assoc_args['format']) {
             \WP_CLI::error(__('Invalid output format requested', 'automattic-cron-control'));
         } else {
             $format = $assoc_args['format'];
         }
     }
     \WP_CLI\Utils\format_items($format, $events_for_display, array('timestamp', 'action', 'instance', 'scheduled_for', 'internal_event', 'schedule_name', 'event_args'));
 }
 /**
  * Adding a new admin
  *
  * @param string $admin_name Name string.
  * @param string $admin_id   ID string.
  *
  * @return string
  */
 public function add_admin($admin_name, $admin_id)
 {
     $success = 0;
     // If one of the fields is empty.
     if (empty($admin_name) || empty($admin_id)) {
         $response_body = $this->get_response_body('not_present');
     } else {
         $admin_id = $this->parse_admin_id($admin_id);
         if (!isset($this->options['fb_admins'][$admin_id])) {
             $name = sanitize_text_field(urldecode($admin_name));
             $admin_id = sanitize_text_field($admin_id);
             if (preg_match('/[0-9]+?/', $admin_id) && preg_match('/[\\w\\s]+?/', $name)) {
                 $this->options['fb_admins'][$admin_id]['name'] = $name;
                 $this->options['fb_admins'][$admin_id]['link'] = urldecode('http://www.facebook.com/' . $admin_id);
                 $this->save_options();
                 $success = 1;
                 $response_body = $this->form->get_admin_link($admin_id, $this->options['fb_admins'][$admin_id]);
             } else {
                 $response_body = $this->get_response_body('invalid_format');
             }
         } else {
             $response_body = $this->get_response_body('already_exists');
         }
     }
     return wp_json_encode(array('success' => $success, 'html' => $response_body));
 }
예제 #8
0
 /**
  * Returns options & contents in JSON format
  *
  * @return string{JSON}
  */
 public function get_json()
 {
     $out = array();
     $out['options'] = self::$options;
     $out['content'] = self::$options;
     return wp_json_encode($out);
 }
 /**
  * Enqueue pointers and add script to page.
  * @param array $pointers
  */
 public function enqueue_pointers($pointers)
 {
     $pointers = wp_json_encode($pointers);
     wp_enqueue_style('wp-pointer');
     wp_enqueue_script('wp-pointer');
     ac_enqueue_js("\n\t\t\tjQuery( function( \$ ) {\n\t\t\t\tvar ac_pointers = {$pointers};\n\n\t\t\t\tsetTimeout( init_ac_pointers, 800 );\n\n\t\t\t\tfunction init_ac_pointers() {\n\t\t\t\t\t\$.each( ac_pointers.pointers, function( i ) {\n\t\t\t\t\t\tshow_ac_pointer( i );\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tfunction show_ac_pointer( id ) {\n\t\t\t\t\tvar pointer = ac_pointers.pointers[ id ];\n\t\t\t\t\tvar options = \$.extend( pointer.options, {\n\t\t\t\t\t\tclose: function() {\n\t\t\t\t\t\t\t\$.post( ajaxurl, {\n\t\t\t\t\t\t\t\tpointer: id,\n\t\t\t\t\t\t\t\taction: 'dismiss-wp-pointer'\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t\tvar this_pointer = \$( pointer.target ).pointer( options );\n\t\t\t\t\tthis_pointer.pointer( 'open' );\n\t\t\t\t}\n\t\t\t});\n\t\t");
 }
예제 #10
0
    /**
     * Get field HTML.
     *
     * @param mixed $meta
     * @param array $field
     * @return string
     */
    static function html($meta, $field)
    {
        if (!is_array($meta)) {
            $meta = (array) $meta;
        }
        // Filter to change the drag & drop box background string
        $i18n_drop = apply_filters('rwmb_plupload_image_drop_string', _x('Drop images here', 'image upload', 'meta-box'), $field);
        $i18n_or = apply_filters('rwmb_plupload_image_or_string', _x('or', 'image upload', 'meta-box'), $field);
        $i18n_select = apply_filters('rwmb_plupload_image_select_string', _x('Select Files', 'image upload', 'meta-box'), $field);
        // Uploaded images
        // Check for max_file_uploads
        $classes = array('rwmb-drag-drop', 'drag-drop', 'hide-if-no-js', 'new-files');
        if (!empty($field['max_file_uploads']) && count($meta) >= (int) $field['max_file_uploads']) {
            $classes[] = 'hidden';
        }
        $html = self::get_uploaded_images($meta, $field);
        // Show form upload
        $html .= sprintf('<div id="%s-dragdrop" class="%s" data-upload_nonce="%s" data-js_options="%s">
				<div class = "drag-drop-inside">
					<p class="drag-drop-info">%s</p>
					<p>%s</p>
					<p class="drag-drop-buttons"><input id="%s-browse-button" type="button" value="%s" class="button" /></p>
				</div>
			</div>', $field['id'], implode(' ', $classes), wp_create_nonce("rwmb-upload-images_{$field['id']}"), esc_attr(wp_json_encode($field['js_options'])), $i18n_drop, $i18n_or, $field['id'], $i18n_select);
        return $html;
    }
예제 #11
0
 /**
  * Get the attributes for a field
  *
  * @param array $field
  * @param mixed $value
  * @return array
  */
 static function get_attributes($field, $value = null)
 {
     $attributes = parent::get_attributes($field, $value);
     $attributes = wp_parse_args($attributes, array('data-options' => wp_json_encode($field['js_options'])));
     $attributes['type'] = 'text';
     return $attributes;
 }
예제 #12
0
/**
 * Translation function
 */
function wps_button_translation()
{
    $strings = array('button_label' => __('WPS Shortcode Helper', 'wps_helper_plugin'), 'msg' => __('Hello World!!!!', 'wps_helper_plugin'));
    $locale = _WP_Editors::$mce_locale;
    $translated = 'tinyMCE.addI18n("' . $locale . '.wps_button", ' . wp_json_encode($strings) . ");\n";
    return $translated;
}
 /**
  * Check the server for theme updates.
  *
  * @param  object $data `update_themes` transient
  * @return object       Transformed `update_themes` transient
  */
 public static function check_for_update($data)
 {
     // Setup
     self::set_theme_data();
     $request = array('slug' => self::$theme_slug, 'version' => self::$theme_version);
     if (defined('DOING_CRON') && DOING_CRON) {
         $timeout = 30;
     } else {
         $timeout = 3;
     }
     $options = array('timeout' => $timeout, 'body' => array('request' => wp_json_encode($request)));
     $raw_response = wp_remote_post(self::$api_url, $options);
     if (is_wp_error($raw_response)) {
         return $raw_response;
     } else {
         if (wp_remote_retrieve_response_code($raw_response) !== 200) {
             return new WP_Error('broke', __('Theme update failed:'), $raw_response);
         }
     }
     $response = json_decode(wp_remote_retrieve_body($raw_response), true);
     if (gettype($response) === 'array' && isset($response['new_version']) && isset($response['url']) && isset($response['package'])) {
         $data->response[self::$theme_slug] = array('theme' => self::$theme_slug, 'new_version' => $response['new_version'], 'url' => $response['url'], 'package' => $response['package']);
     }
     return $data;
 }
예제 #14
0
 private function _respond()
 {
     $response = array('results' => $this->_results);
     echo wp_json_encode($response);
     wp_die();
     // this is required to terminate immediately and return a proper response
 }
 function ajax_response()
 {
     check_ajax_referer('ajax-custom-list-nonce', '_ajax_custom_list_nonce');
     $this->prepare_items();
     extract($this->_args);
     extract($this->_pagination_args, EXTR_SKIP);
     ob_start();
     if (!empty($_REQUEST['no_placeholder'])) {
         $this->display_rows();
     } else {
         $this->display_rows_or_placeholder();
     }
     $rows = ob_get_clean();
     ob_start();
     $this->print_column_headers();
     $headers = ob_get_clean();
     ob_start();
     $this->pagination('top');
     $pagination_top = ob_get_clean();
     ob_start();
     $this->pagination('bottom');
     $pagination_bottom = ob_get_clean();
     $response = array('rows' => $rows);
     $response['pagination']['top'] = $pagination_top;
     $response['pagination']['bottom'] = $pagination_bottom;
     $response['column_headers'] = $headers;
     if (isset($total_items)) {
         $response['total_items_i18n'] = sprintf(_n('1 item', '%s items', $total_items), number_format_i18n($total_items));
     }
     if (isset($total_pages)) {
         $response['total_pages'] = $total_pages;
         $response['total_pages_i18n'] = number_format_i18n($total_pages);
     }
     die(wp_json_encode($response));
 }
예제 #16
0
/**
 * Display JavaScript on the page.
 *
 * @since 3.5.0
 */
function options_general_add_js()
{
    ?>
<script type="text/javascript">
//<![CDATA[
	jQuery(document).ready(function($){
		var $siteName = $( '#wp-admin-bar-site-name' ).children( 'a' ).first(),
			homeURL = ( <?php 
    echo wp_json_encode(get_home_url());
    ?>
 || '' ).replace( /^(https?:\/\/)?(www\.)?/, '' );

		$( '#blogname' ).on( 'input', function() {
			var title = $.trim( $( this ).val() ) || homeURL;

			// Truncate to 40 characters.
			if ( 40 < title.length ) {
				title = title.substring( 0, 40 ) + '\u2026';
			}

			$siteName.text( title );
		});

		$("input[name='date_format']").click(function(){
			if ( "date_format_custom_radio" != $(this).attr("id") )
				$("input[name='date_format_custom']").val( $(this).val() ).siblings('.example').text( $(this).siblings('span').text() );
		});
		$("input[name='date_format_custom']").focus(function(){
			$( '#date_format_custom_radio' ).prop( 'checked', true );
		});

		$("input[name='time_format']").click(function(){
			if ( "time_format_custom_radio" != $(this).attr("id") )
				$("input[name='time_format_custom']").val( $(this).val() ).siblings('.example').text( $(this).siblings('span').text() );
		});
		$("input[name='time_format_custom']").focus(function(){
			$( '#time_format_custom_radio' ).prop( 'checked', true );
		});
		$("input[name='date_format_custom'], input[name='time_format_custom']").change( function() {
			var format = $(this);
			format.siblings('.spinner').css('display', 'inline-block'); // show(); can't be used here
			$.post(ajaxurl, {
					action: 'date_format_custom' == format.attr('name') ? 'date_format' : 'time_format',
					date : format.val()
				}, function(d) { format.siblings('.spinner').hide(); format.siblings('.example').text(d); } );
		});

		var languageSelect = $( '#WPLANG' );
		$( 'form' ).submit( function() {
			// Don't show a spinner for English and installed languages,
			// as there is nothing to download.
			if ( ! languageSelect.find( 'option:selected' ).data( 'installed' ) ) {
				$( '#submit', this ).after( '<span class="spinner language-install-spinner" />' );
			}
		});
	});
//]]>
</script>
<?php 
}
예제 #17
0
function jwplayer_admin_head()
{
    $plugin_url = plugins_url('', __FILE__);
    $content_mask = jwplayer_get_content_mask();
    if ($content_mask === JWPLAYER_CONTENT_MASK && is_ssl()) {
        $content_mask = 'https://' . $content_mask;
    }
    $nr_videos = intval(get_option('jwplayer_nr_videos'));
    ?>

	<script type="text/javascript">
		jwplayerwp.plugin_url = '<?php 
    echo esc_url($plugin_url);
    ?>
';
		jwplayerwp.content_mask = '<?php 
    echo esc_url($content_mask);
    ?>
';
		jwplayerwp.nr_videos = <?php 
    echo esc_js($nr_videos);
    ?>
;
		jwplayerwp.debug = <?php 
    echo wp_json_encode(WP_DEBUG);
    ?>
;
	</script>
	<?php 
}
예제 #18
0
/**
 * Hook in and add a demo metabox. Can only happen on the 'cmb2_init' hook.
 */
function yourprefix_register_conditionals_demo_metabox()
{
    // Start with an underscore to hide fields from custom fields list.
    $prefix = '_yourprefix_conditions_demo_';
    /**
     * Sample metabox to demonstrate the different conditions you can set.
     */
    $cmb_demo = new_cmb2_box(array('id' => $prefix . 'metabox', 'title' => 'Test Metabox', 'object_types' => array('page')));
    $cmb_demo->add_field(array('name' => 'Address', 'desc' => 'Write down an address for showing the other address options', 'id' => $prefix . 'address', 'type' => 'text'));
    $cmb_demo->add_field(array('name' => 'Zipcode', 'id' => $prefix . 'zipcode', 'type' => 'text_medium', 'attributes' => array('required' => true, 'data-conditional-id' => $prefix . 'address')));
    $cmb_demo->add_field(array('name' => 'Country', 'id' => $prefix . 'country', 'type' => 'text_medium', 'attributes' => array('required' => true, 'data-conditional-id' => $prefix . 'address')));
    $cmb_demo->add_field(array('name' => 'Checkbox', 'id' => $prefix . 'checkbox', 'type' => 'checkbox'));
    $cmb_demo->add_field(array('name' => 'Show if checked', 'id' => $prefix . 'show_if_checked', 'type' => 'text', 'attributes' => array('data-conditional-id' => $prefix . 'checkbox')));
    $cmb_demo->add_field(array('name' => 'Show if unchecked', 'id' => $prefix . 'show_if_unchecked', 'type' => 'text', 'attributes' => array('data-conditional-id' => $prefix . 'checkbox', 'data-conditional-value' => 'off')));
    $cmb_demo->add_field(array('name' => 'Reason', 'id' => $prefix . 'reason', 'type' => 'select', 'show_option_none' => true, 'options' => array('one' => 'Reason 1', 'two' => 'Reason 2', 'three' => 'Reason 3', 'other' => 'Other reason')));
    $cmb_demo->add_field(array('name' => 'Other reason detail', 'desc' => 'Write down the reason', 'id' => $prefix . 'other_reason_detail', 'type' => 'textarea', 'attributes' => array('required' => true, 'data-conditional-id' => $prefix . 'reason', 'data-conditional-value' => 'other')));
    $cmb_demo->add_field(array('name' => 'Reason 2', 'id' => $prefix . 'reason_2', 'type' => 'select', 'show_option_none' => true, 'options' => array('one' => 'Reason 1', 'two' => 'Reason 2', 'three' => 'Reason 3', 'other_price' => 'Other reason based on the price', 'other_quality' => 'Other reason based on the quality')));
    $cmb_demo->add_field(array('name' => 'Other reason detail', 'desc' => 'Write down the reason', 'id' => $prefix . 'other_reason_detail_2', 'type' => 'textarea', 'attributes' => array('required' => true, 'data-conditional-id' => $prefix . 'reason_2', 'data-conditional-value' => wp_json_encode(array('other_price', 'other_quality')))));
    $cmb_demo->add_field(array('name' => 'Sizes', 'id' => $prefix . 'sizes', 'type' => 'radio', 'show_option_none' => true, 'options' => array('xs' => 'XS', 's' => 'S', 'm' => 'M', 'l' => 'L', 'xl' => 'XL', 'custom' => 'Custom'), 'attributes' => array('required' => 'required')));
    $cmb_demo->add_field(array('name' => 'Custom description', 'desc' => 'Write a description for your custom size', 'id' => $prefix . 'size_custom_description', 'type' => 'textarea', 'required' => true, 'attributes' => array('required' => true, 'data-conditional-id' => $prefix . 'sizes', 'data-conditional-value' => 'custom')));
    // Example using conditionals with multi-check checkboxes.
    $cmb_demo->add_field(array('name' => __('Test Multi Checkbox', 'cmb2'), 'desc' => __('field description (optional)', 'cmb2'), 'id' => $prefix . 'multi-checkbox', 'type' => 'multicheck', 'options' => array('check1' => __('Check One', 'cmb2'), 'check2' => __('Check Two', 'cmb2'), 'check3' => __('Check Three', 'cmb2'))));
    $cmb_demo->add_field(array('name' => 'Multi-check: Shown if *any* checkbox is checked', 'id' => $prefix . 'multi-check-detail-test-no-value', 'type' => 'text', 'attributes' => array('required' => true, 'data-conditional-id' => $prefix . 'multi-checkbox')));
    $cmb_demo->add_field(array('name' => 'Multi-check: Only shown if checkbox 2 is checked', 'id' => $prefix . 'multi-check-detail-test-string', 'type' => 'text', 'attributes' => array('data-conditional-id' => $prefix . 'multi-checkbox', 'data-conditional-value' => 'check2')));
    $cmb_demo->add_field(array('name' => 'Multi-check : Shown if either checkbox 1 *or* 3 is checked', 'id' => $prefix . 'multi-check-detail-test-array', 'type' => 'text', 'attributes' => array('data-conditional-id' => $prefix . 'multi-checkbox', 'data-conditional-value' => wp_json_encode(array('check1', 'check3')))));
    // Example conditionals within a group.
    $group_id = $cmb_demo->add_field(array('id' => $prefix . 'repeatable-group', 'type' => 'group', 'description' => 'Repeatable group', 'options' => array('group_title' => 'Entry {#}', 'add_button' => 'Add Another Entry', 'remove_button' => 'Remove Entry', 'sortable' => true)));
    $cmb_demo->add_group_field($group_id, array('name' => 'Checkbox in group', 'id' => 'checkbox', 'type' => 'checkbox'));
    $cmb_demo->add_group_field($group_id, array('name' => 'Dependant field', 'id' => 'dependant', 'type' => 'text_small', 'attributes' => array('required' => true, 'data-conditional-id' => wp_json_encode(array($group_id, 'checkbox')), 'data-conditional-value' => 'on')));
}
 /**
  * Logs with an arbitrary level.
  *
  * @param mixed $level
  * @param string $message
  * @param array $context
  * @return null
  */
 public function log($level, $message, array $context = array())
 {
     $data = compact('level', 'message');
     switch ($level) {
         case 'emergency':
         case 'alert':
         case 'critical':
         case 'error':
         case 'warning':
         case 'notice':
         case 'info':
             echo "event: log\n";
             echo 'data: ' . wp_json_encode($data) . "\n\n";
             flush();
             break;
         case 'debug':
             if (defined('IMPORT_DEBUG') && IMPORT_DEBUG) {
                 echo "event: log\n";
                 echo 'data: ' . wp_json_encode($data) . "\n\n";
                 flush();
                 break;
             }
             break;
     }
 }
function nf_tmp_frontendform($atts = array())
{
    $form_id = $atts['id'];
    wp_enqueue_script('backbone-marionette', Ninja_Forms::$url . 'assets/js/lib/backbone.marionette.min.js', array('jquery', 'backbone'));
    wp_enqueue_script('backbone-radio', Ninja_Forms::$url . 'assets/js/lib/backbone.radio.min.js', array('jquery', 'backbone'));
    wp_enqueue_script('requirejs', Ninja_Forms::$url . 'assets/js/lib/require.js', array('jquery', 'backbone'));
    wp_enqueue_script('nf-front-end', Ninja_Forms::$url . 'assets/js/front-end/main.js', array('jquery', 'backbone', 'requirejs', 'jquery-form'));
    wp_localize_script('nf-front-end', 'nfFrontEnd', array('ajaxNonce' => wp_create_nonce('ninja_forms_ajax_nonce'), 'adminAjax' => admin_url('admin-ajax.php'), 'requireBaseUrl' => Ninja_Forms::$url . 'assets/js/'));
    switch ($form_id) {
        case 1:
            $title = 'Contact Me';
            $fields = array(array('id' => 1, 'type' => 'text', 'label' => 'Name', 'label_pos' => 'before', 'required' => 1), array('id' => 8, 'type' => 'email', 'label' => 'Email', 'label_pos' => 'before', 'required' => 1), array('id' => 11, 'type' => 'text', 'label' => 'Confirm Email', 'label_pos' => 'before', 'confirm_field' => 8, 'required' => 1), array('id' => 13, 'type' => 'file', 'label' => 'Attachment', 'button_label' => 'Upload', 'label_pos' => 'before', 'required' => 0), array('id' => 2, 'type' => 'textarea', 'label' => 'Message', 'label_pos' => 'before', 'required' => 1), array('id' => 10, 'type' => 'text', 'label' => 'Mirror Name', 'label_pos' => 'before', 'mirror_field' => 1), array('id' => 3, 'type' => 'submit', 'label' => 'Go!'));
            break;
        case 2:
            $title = 'Get Help';
            $fields = array(array('id' => 4, 'type' => 'text', 'label' => 'Name', 'label_pos' => 'before', 'required' => 1), array('id' => 12, 'type' => 'email', 'label' => 'Email', 'label_pos' => 'before', 'required' => 1), array('id' => 5, 'type' => 'textarea', 'label' => 'What Can We Help You With?', 'label_pos' => 'before', 'required' => 1), array('id' => 6, 'type' => 'checkbox', 'label' => 'Agree?', 'label_pos' => 'after', 'required' => 1), array('id' => 9, 'type' => 'radio', 'label' => 'Best Contact Method?', 'label_pos' => 'before', 'options' => array(array('label' => 'Phone', 'value' => 'phone'), array('label' => 'Email', 'value' => 'email'), array('label' => 'Snail Mail', 'value' => 'snail-mail')), 'show_other' => 1, 'required' => 1), array('id' => 7, 'type' => 'submit', 'label' => 'Send'));
            break;
    }
    $form = array(array('id' => $form_id, 'settings' => array('title' => $title), 'fields' => $fields));
    ?>
	<script type="text/javascript">
		var nfForms = nfForms || [];
		nfForms.push( <?php 
    echo wp_json_encode($form);
    ?>
 );
	</script>

	<?php 
    nf_tmp_output_templates();
    $html = '<div id="nf-form-' . $form_id . '-cont"></div>';
    return $html;
}
예제 #21
0
 public static function maybe_get_free_license()
 {
     if (!isset($_REQUEST['security'])) {
         self::ajax_fail('Forget something?');
     }
     $nonce = $_REQUEST['security'];
     if (!wp_verify_nonce($nonce, self::NONCE)) {
         self::ajax_fail('Not going to fall for it!');
     }
     if (!current_user_can('activate_plugins')) {
         return;
     }
     if (!isset($_REQUEST['license'])) {
         self::ajax_fail('No email submitted');
     }
     if (!is_email($_REQUEST['license'])) {
         self::ajax_fail('No Email Submitted');
     }
     $license_response = self::get_free_license($_REQUEST['license']);
     if (is_object($license_response)) {
         $message = self::__('Thank you for registering Sprout Invoices with Sprout Apps.');
         $response = array('license' => $license_response->license_key, 'uid' => $license_response->uid, 'response' => $message, 'error' => !isset($license_response->license_key));
         update_option(self::LICENSE_KEY_OPTION, $license_response->license_key);
         update_option(self::LICENSE_UID_OPTION, $license_response->uid);
     } else {
         $message = self::__('License not created.');
         $response = array('response' => $message, 'error' => 1);
     }
     header('Content-type: application/json');
     echo wp_json_encode($response);
     exit;
 }
예제 #22
0
파일: db.php 프로젝트: pojome/elementor
 /**
  * Save builder method.
  *
  * @since 1.0.0
  * @param int    $post_id
  * @param array  $posted
  * @param string $revision
  *
  * @return void
  */
 public function save_editor($post_id, $posted, $revision = self::REVISION_PUBLISH)
 {
     // Change the global post to current library post, so widgets can use `get_the_ID` and other post data
     if (isset($GLOBALS['post'])) {
         $global_post = $GLOBALS['post'];
     }
     $GLOBALS['post'] = get_post($post_id);
     $editor_data = $this->_get_editor_data($posted);
     // We need the `wp_slash` in order to avoid the unslashing during the `update_post_meta`
     $json_value = wp_slash(wp_json_encode($editor_data));
     if (self::REVISION_PUBLISH === $revision) {
         $this->remove_draft($post_id);
         update_post_meta($post_id, '_elementor_data', $json_value);
         $this->_save_plain_text($post_id);
     } else {
         update_post_meta($post_id, '_elementor_draft_data', $json_value);
     }
     update_post_meta($post_id, '_elementor_version', self::DB_VERSION);
     // Restore global post
     if (isset($global_post)) {
         $GLOBALS['post'] = $global_post;
     } else {
         unset($GLOBALS['post']);
     }
 }
 /**
  * Enqueue pointers and add script to page.
  * @param array $pointers
  */
 public function enqueue_pointers($pointers)
 {
     $pointers = wp_json_encode($pointers);
     wp_enqueue_style('wp-pointer');
     wp_enqueue_script('wp-pointer');
     wc_enqueue_js("\n\t\t\tjQuery( function( \$ ) {\n\t\t\t\tvar wc_pointers = {$pointers};\n\n\t\t\t\tsetTimeout( init_wc_pointers, 800 );\n\n\t\t\t\tfunction init_wc_pointers() {\n\t\t\t\t\t\$.each( wc_pointers.pointers, function( i ) {\n\t\t\t\t\t\tshow_wc_pointer( i );\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tfunction show_wc_pointer( id ) {\n\t\t\t\t\tvar pointer = wc_pointers.pointers[ id ];\n\t\t\t\t\tvar options = \$.extend( pointer.options, {\n\t\t\t\t\t\tclose: function() {\n\t\t\t\t\t\t\tif ( pointer.next ) {\n\t\t\t\t\t\t\t\tshow_wc_pointer( pointer.next );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t\tvar this_pointer = \$( pointer.target ).pointer( options );\n\t\t\t\t\tthis_pointer.pointer( 'open' );\n\n\t\t\t\t\tif ( pointer.next_trigger ) {\n\t\t\t\t\t\t\$( pointer.next_trigger.target ).on( pointer.next_trigger.event, function() {\n\t\t\t\t\t\t\tsetTimeout( function() { this_pointer.pointer( 'close' ); }, 400 );\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t");
 }
function json_get_user_avatar_info($user_id)
{
    global $avatar_table;
    global $wpdb;
    $query = "SELECT * FROM " . $avatar_table . " WHERE user_id = " . $user_id;
    $result = $wpdb->get_results($query, ARRAY_A);
    return wp_json_encode($result);
}
예제 #25
0
	function set_customized_post_data( $customized ) {
		$_POST['customized'] = wp_slash( wp_json_encode( $customized ) );
		if ( $this->manager ) {
			foreach ( $customized as $id => $value ) {
				$this->manager->set_post_value( $id, $value );
			}
		}
	}
예제 #26
0
 /**
  * Outputs a small piece of javascript for the beacon
  */
 public function output_beacon_js()
 {
     /** @noinspection PhpUnusedLocalVariableInspection */
     $data = wp_json_encode($this->localize_beacon());
     echo '<script type="text/javascript">';
     require dirname(__FILE__) . '/yoast-seo-helpscout-beacon.js.php';
     echo '</script>';
 }
예제 #27
0
파일: color.php 프로젝트: riopse/meta-box
 /**
  * Normalize parameters for field
  *
  * @param array $field
  *
  * @return array
  */
 static function normalize_field($field)
 {
     $field = wp_parse_args($field, array('size' => 7, 'maxlength' => 7, 'pattern' => '^#+([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$', 'js_options' => array()));
     $field['js_options'] = wp_parse_args($field['js_options'], array('defaultColor' => false, 'hide' => true, 'palettes' => true));
     $field = parent::normalize_field($field);
     $field['attributes'] = wp_parse_args($field['attributes'], array('data-options' => wp_json_encode($field['js_options'])));
     return $field;
 }
예제 #28
0
 public function AddFrontFooter()
 {
     $fdc_vars = array('nonce' => wp_create_nonce('fdc_nonce'));
     $output = "var fdc_vars = " . wp_json_encode($fdc_vars) . ';';
     echo "\n<script type='text/javascript'>\n";
     echo "{$output}\n";
     echo "</script>\n";
 }
예제 #29
0
파일: slider.php 프로젝트: rilwis/meta-box
    /**
     * Get div HTML
     *
     * @param mixed $meta
     * @param array $field
     *
     * @return string
     */
    static function html($meta, $field)
    {
        return sprintf('<div class="clearfix">
				<div class="rwmb-slider" id="%s" data-options="%s"></div>
				<span class="rwmb-slider-value-label">%s<span>%s</span>%s</span>
				<input type="hidden" name="%s" value="%s" class="rwmb-slider-value">
			</div>', $field['id'], esc_attr(wp_json_encode($field['js_options'])), $field['prefix'], $meta >= 0 ? $meta : $field['std'], $field['suffix'], $field['field_name'], $meta >= 0 ? $meta : $field['std']);
    }
예제 #30
0
 /**
  * Get field HTML
  *
  * @param mixed $meta
  * @param array $field
  *
  * @return string
  */
 static function html($meta, $field)
 {
     $html = sprintf('<select class="rwmb-select-advanced" name="%s" id="%s" size="%s"%s data-options="%s">', $field['field_name'], $field['id'], $field['size'], $field['multiple'] ? ' multiple' : '', esc_attr(wp_json_encode($field['js_options'])));
     $html .= self::options_html($field, $meta);
     $html .= '</select>';
     $html .= self::get_select_all_html($field['multiple']);
     return $html;
 }