plugin install

This commit is contained in:
Tony Volpe
2024-06-18 17:29:05 -04:00
parent e1aaedd1ae
commit 41f50eacc4
5880 changed files with 1057631 additions and 39681 deletions

View File

@@ -0,0 +1,68 @@
<?php
namespace Gravity_Forms\Gravity_Forms\Embed_Form\Endpoints;
/**
* AJAX Endpoint for creating a new post with a specific block already added.
*
* @since 2.6
*
* @package Gravity_Forms\Gravity_Forms\Embed_Form\Endpoints
*/
class GF_Embed_Endpoint_Create_With_Block {
// Strings
const ACTION_NAME = 'gf_embed_create_post_with_block';
// Request Params
const PARAM_FORM_ID = 'form_id';
const PARAM_POST_TYPE = 'post_type';
const PARAM_POST_TITLE = 'post_title';
/**
* Handle the AJAX request.
*
* @since 2.6
*
* @return void
*/
public function handle() {
check_ajax_referer( self::ACTION_NAME );
$post_type = rgpost( self::PARAM_POST_TYPE );
$form_id = rgpost( self::PARAM_FORM_ID );
$post_title = rgpost( self::PARAM_POST_TITLE );
if ( empty( $post_type ) || empty( $form_id ) ) {
wp_send_json_error( 'Request must include a post_type and form_id.', 400 );
}
$post_data = array(
'post_title' => $post_title,
'post_type' => $post_type,
'post_content' => $this->get_content_for_form( $form_id ),
);
$new_id = wp_insert_post( $post_data );
wp_send_json_success( array( 'ID' => $new_id ) );
}
/**
* Get the properly-formatted comment string for the block we're inserting.
*
* @since 2.6
*
* @param $form_id
*
* @return string
*/
private function get_content_for_form( $form_id ) {
$attrs = array(
'formId' => $form_id
);
return get_comment_delimited_block_content( 'gravityforms/form', $attrs, '' );
}
}

View File

@@ -0,0 +1,69 @@
<?php
namespace Gravity_Forms\Gravity_Forms\Embed_Form\Endpoints;
/**
* AJAX Endpoint for getting posts based on search params.
*
* @since 2.6
*
* @package Gravity_Forms\Gravity_Forms\Embed_Form\Endpoints
*/
class GF_Embed_Endpoint_Get_Posts {
// Strings
const ACTION_NAME = 'gf_embed_query_posts';
// Parameters
const PARAM_OFFSET = 'offset';
const PARAM_COUNT = 'count';
const PARAM_STATUS = 'status';
const PARAM_SEARCH = 'search';
const PARAM_POST_TYPE = 'post_type';
// Defaults
const DEFAULT_OFFSET = 0;
const DEFAULT_COUNT = 10;
const DEFAULT_STATUS = 'publish';
const DEFAULT_SEARCH = '';
const DEFAULT_POST_TYPE = 'post';
/**
* Handle the AJAX request.
*
* @since 2.6
*
* @return void
*/
public function handle() {
check_ajax_referer( self::ACTION_NAME );
$offset = rgpost( self::PARAM_OFFSET ) ? rgpost( self::PARAM_OFFSET ) : self::DEFAULT_OFFSET;
$count = rgpost( self::PARAM_COUNT ) ? rgpost( self::PARAM_COUNT ) : self::DEFAULT_COUNT;
$status = rgpost( self::PARAM_STATUS ) ? rgpost( self::PARAM_STATUS ) : self::DEFAULT_STATUS;
$search = rgpost( self::PARAM_SEARCH ) ? rgpost( self::PARAM_SEARCH ) : self::DEFAULT_SEARCH;
$post_type = rgpost( self::PARAM_POST_TYPE ) ? rgpost( self::PARAM_POST_TYPE ) : self::DEFAULT_POST_TYPE;
$args = array(
'post_type' => $post_type,
'post_status' => $status,
'posts_per_page' => $count,
'offset' => $offset,
's' => $search,
);
$query = new \WP_Query( $args );
$posts = $query->get_posts();
array_walk( $posts, function ( &$post ) {
$post = array(
'value' => $post->ID,
'label' => $post->post_title,
);
} );
wp_send_json_success( $posts );
}
}