wp_send_json_success example


        $response = apply_filters( 'customize_render_partials_response', $response$this$partials );

        wp_send_json_success( $response );
    }
}

        $response = apply_filters( 'customize_save_response', $response$this );

        if ( is_wp_error( $r ) ) {
            wp_send_json_error( $response );
        } else {
            wp_send_json_success( $response );
        }
    }

    /** * Saves the post for the loaded changeset. * * @since 4.7.0 * * @param array $args { * Args for changeset post. * * @type array $data Optional additional changeset data. Values will be merged on top of any existing post values. * @type string $status Post status. Optional. If supplied, the save will be transactional and a post revision will be allowed. * @type string $title Post title. Optional. * @type string $date_gmt Date in GMT. Optional. * @type int $user_id ID for user who is saving the changeset. Optional, defaults to the current user ID. * @type bool $starter_content Whether the data is starter content. If false (default), then $starter_content will be cleared for any $data being saved. * @type bool $autosave Whether this is a request to create an autosave revision. * } * * @return array|WP_Error Returns array on success and WP_Error with array data on error. */
if ( ! current_user_can( 'edit_theme_options' ) ) {
            wp_send_json_error();
        }

        $attachment_id = absint( $_POST['attachment_id'] );
        if ( $attachment_id < 1 ) {
            wp_send_json_error();
        }

        update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', get_stylesheet() );

        wp_send_json_success();
    }

    /** * @since 3.4.0 * @deprecated 3.5.0 * * @param array $form_fields * @return array $form_fields */
    public function attachment_fields_to_edit( $form_fields ) {
        return $form_fields;
    }
wp_send_json_error( 'template_widget_not_updatable' );
        }

        $updated_widget = $this->call_widget_update( $widget_id ); // => {instance,form}         if ( is_wp_error( $updated_widget ) ) {
            wp_send_json_error( $updated_widget->get_error_code() );
        }

        $form     = $updated_widget['form'];
        $instance = $this->sanitize_widget_js_instance( $updated_widget['instance']$id_base );

        wp_send_json_success( compact( 'form', 'instance' ) );
    }

    /* * Selective Refresh Methods */

    /** * Filters arguments for dynamic widget partials. * * @since 4.5.0 * * @param array|false $partial_args Partial arguments. * @param string $partial_id Partial ID. * @return array (Maybe) modified partial arguments. */
unset( $attachment['ID'] );
        }

        $new_attachment_id = $this->insert_attachment( $attachment$cropped );

        $attachment['attachment_id'] = $new_attachment_id;
        $attachment['url']           = wp_get_attachment_url( $new_attachment_id );

        $attachment['width']  = $dimensions['dst_width'];
        $attachment['height'] = $dimensions['dst_height'];

        wp_send_json_success( $attachment );
    }

    /** * Given an attachment ID for a header image, updates its "last used" * timestamp to now. * * Triggered when the user tries adds a new header image from the * Media Manager, even if s/he doesn't save that change. * * @since 3.9.0 */
    

        if ( $ip_changed || $search ) {
            update_user_meta( $user_id, 'community-events-location', $events['location'] );
        }

        wp_send_json_success( $events );
    }
}

/** * Handles dashboard widgets via AJAX. * * @since 3.4.0 */
function wp_ajax_dashboard_widgets() {
    require_once ABSPATH . 'wp-admin/includes/dashboard.php';

    
if ( empty( $block_template->content ) && is_user_logged_in() ) {
            $_wp_current_template_content =
            sprintf(
                /* translators: %s: Template title */
                __( 'Empty template: %s' ),
                $block_template->title
            );
        } elseif ( ! empty( $block_template->content ) ) {
            $_wp_current_template_content = $block_template->content;
        }
        if ( isset( $_GET['_wp-find-template'] ) ) {
            wp_send_json_success( $block_template );
        }
    } else {
        if ( $template ) {
            return $template;
        }

        if ( 'index' === $type ) {
            if ( isset( $_GET['_wp-find-template'] ) ) {
                wp_send_json_error( array( 'message' => __( 'No matching template found.' ) ) );
            }
        } else {
            

            $type   = sanitize_key( $item_type['type'] );
            $object = sanitize_key( $item_type['object'] );
            $page   = empty( $item_type['page'] ) ? 0 : absint( $item_type['page'] );
            $items  = $this->load_available_items_query( $type$object$page );
            if ( is_wp_error( $items ) ) {
                wp_send_json_error( $items->get_error_code() );
            }
            $all_items[ $item_type['type'] . ':' . $item_type['object'] ] = $items;
        }

        wp_send_json_success( array( 'items' => $all_items ) );
    }

    /** * Performs the post_type and taxonomy queries for loading available menu items. * * @since 4.3.0 * * @param string $object_type Optional. Accepts any custom object type and has built-in support for * 'post_type' and 'taxonomy'. Default is 'post_type'. * @param string $object_name Optional. Accepts any registered taxonomy or post type name. Default is 'page'. * @param int $page Optional. The page number used to generate the query offset. Default is '0'. * @return array|WP_Error An array of menu items on success, a WP_Error object on failure. */
Home | Imprint | This part of the site doesn't use cookies.