trying to insert acf custom field to front
This commit is contained in:
@@ -39,8 +39,9 @@ inclusions
|
|||||||
*/
|
*/
|
||||||
include_once(PLGNTLS_class::get_path() . '/php/utils/globals.php');
|
include_once(PLGNTLS_class::get_path() . '/php/utils/globals.php');
|
||||||
include_once(PLGNTLS_class::get_path() . '/php/menu/example_menu.php');
|
include_once(PLGNTLS_class::get_path() . '/php/menu/example_menu.php');
|
||||||
include_once(PLGNTLS_class::get_path() . '/php/images/image-edit.php');
|
|
||||||
|
|
||||||
|
//include_once(PLGNTLS_class::get_path() . '/php/images/image_edit_shortcode.php');
|
||||||
|
//include_once(PLGNTLS_class::get_path() . '/php/images/image-edit.php');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -112,88 +113,21 @@ $data = $data->user_email;
|
|||||||
add_shortcode('fipfcard_plugin', 'fipfcard_main_shortcode');
|
add_shortcode('fipfcard_plugin', 'fipfcard_main_shortcode');
|
||||||
|
|
||||||
|
|
||||||
function fipfcard_image_editor()
|
function custom_frontend_posting_form() {
|
||||||
{
|
$my_image = the_field('image_ratio');
|
||||||
// ob_start();
|
error_log("my_image");
|
||||||
// wp_image_editor('33545');
|
error_log(json_encode($my_image));
|
||||||
// return ob_get_clean();
|
return $my_image;
|
||||||
$test1 = "hello";
|
|
||||||
$test2 = "you";
|
|
||||||
$fipfcard_image_editor = new PLGNTLS_class();
|
|
||||||
return $fipfcard_image_editor->add_to_front(
|
|
||||||
array(
|
|
||||||
"js/image_editor.js",
|
|
||||||
"html/image_editor.html",
|
|
||||||
),
|
|
||||||
compact(
|
|
||||||
"test1",
|
|
||||||
"test2",
|
|
||||||
)
|
|
||||||
);
|
|
||||||
/*
|
|
||||||
if ( ! has_action( "wp_ajax_{$action}" ) ) {
|
|
||||||
it returns error 400
|
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
add_shortcode('fipfcard_image_editor', 'fipfcard_image_editor');
|
add_shortcode('custom_frontend_posting_form', 'custom_frontend_posting_form');
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles image editing via AJAX.
|
|
||||||
* from wp-admin/includes/ajax-action.php
|
|
||||||
*/
|
|
||||||
function wp_ajax_image_editor_PLGNTLS() {
|
|
||||||
$attachment_id = (int) $_POST['postid'];
|
|
||||||
// $attachment_id = 33555;
|
|
||||||
|
|
||||||
// if ( empty( $attachment_id ) || ! current_user_can( 'edit_post', $attachment_id ) ) {
|
|
||||||
// wp_die( -1 );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// check_ajax_referer( "image_editor-$attachment_id" );
|
|
||||||
// require_once ABSPATH . 'wp-admin/includes/image-edit.php';
|
|
||||||
|
|
||||||
$msg = false;
|
|
||||||
|
|
||||||
switch ( $_POST['do'] ) {
|
|
||||||
case 'save':
|
|
||||||
$msg = wp_save_image( $attachment_id );
|
|
||||||
if ( ! empty( $msg->error ) ) {
|
|
||||||
wp_send_json_error( $msg );
|
|
||||||
}
|
|
||||||
|
|
||||||
wp_send_json_success( $msg );
|
|
||||||
break;
|
|
||||||
case 'scale':
|
|
||||||
$msg = wp_save_image( $attachment_id );
|
|
||||||
break;
|
|
||||||
case 'restore':
|
|
||||||
$msg = wp_restore_image( $attachment_id );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ob_start();
|
|
||||||
wp_image_editor( $attachment_id, $msg );
|
|
||||||
$html = ob_get_clean();
|
|
||||||
|
|
||||||
if ( ! empty( $msg->error ) ) {
|
|
||||||
wp_send_json_error(
|
|
||||||
array(
|
|
||||||
'message' => $msg,
|
|
||||||
'html' => $html,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
wp_send_json_success(
|
|
||||||
array(
|
|
||||||
'message' => $msg,
|
|
||||||
'html' => $html,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
add_action( 'wp_ajax_image_editor_PLGNTLS', 'wp_ajax_image_editor_PLGNTLS' );
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
1463
plugins/fipfcard_plugin/js/images/image-edit.js
Normal file
1463
plugins/fipfcard_plugin/js/images/image-edit.js
Normal file
File diff suppressed because it is too large
Load Diff
23
plugins/fipfcard_plugin/php/images/acf_form.php
Normal file
23
plugins/fipfcard_plugin/php/images/acf_form.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php acf_form_head(); ?>
|
||||||
|
<?php get_header(); ?>
|
||||||
|
|
||||||
|
<div id="primary">
|
||||||
|
<div id="content" role="main">
|
||||||
|
|
||||||
|
<?php /* The loop */ ?>
|
||||||
|
<?php while ( have_posts() ) : the_post(); ?>
|
||||||
|
|
||||||
|
<h1><?php the_title(); ?></h1>
|
||||||
|
|
||||||
|
<?php the_content(); ?>
|
||||||
|
|
||||||
|
<p>My custom field: <?php the_field('my_custom_field'); ?></p>
|
||||||
|
|
||||||
|
<?php acf_form(); ?>
|
||||||
|
|
||||||
|
<?php endwhile; ?>
|
||||||
|
|
||||||
|
</div><!-- #content -->
|
||||||
|
</div><!-- #primary -->
|
||||||
|
|
||||||
|
<?php get_footer(); ?>
|
||||||
82
plugins/fipfcard_plugin/php/images/image_edit_shortcode.php
Normal file
82
plugins/fipfcard_plugin/php/images/image_edit_shortcode.php
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
function fipfcard_image_editor()
|
||||||
|
{
|
||||||
|
// ob_start();
|
||||||
|
// wp_image_editor('33545');
|
||||||
|
// return ob_get_clean();
|
||||||
|
$fipfcard_image_editor = new PLGNTLS_class();
|
||||||
|
return $fipfcard_image_editor->add_to_front(
|
||||||
|
array(
|
||||||
|
"js/image_editor.js",
|
||||||
|
"html/image_editor.html",
|
||||||
|
)
|
||||||
|
);
|
||||||
|
// if ( ! has_action( "wp_ajax_{$action}" ) ) {
|
||||||
|
// it returns error 400
|
||||||
|
|
||||||
|
}
|
||||||
|
add_shortcode('fipfcard_image_editor', 'fipfcard_image_editor');
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles image editing via AJAX.
|
||||||
|
* from wp-admin/includes/ajax-action.php
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
function wp_ajax_image_editor() {
|
||||||
|
$attachment_id = (int) $_POST['postid'];
|
||||||
|
// $attachment_id = 33555;
|
||||||
|
|
||||||
|
// if ( empty( $attachment_id ) || ! current_user_can( 'edit_post', $attachment_id ) ) {
|
||||||
|
// wp_die( -1 );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// check_ajax_referer( "image_editor-$attachment_id" );
|
||||||
|
// require_once ABSPATH . 'wp-admin/includes/image-edit.php';
|
||||||
|
|
||||||
|
$msg = false;
|
||||||
|
|
||||||
|
switch ( $_POST['do'] ) {
|
||||||
|
case 'save':
|
||||||
|
$msg = wp_save_image( $attachment_id );
|
||||||
|
if ( ! empty( $msg->error ) ) {
|
||||||
|
wp_send_json_error( $msg );
|
||||||
|
}
|
||||||
|
|
||||||
|
wp_send_json_success( $msg );
|
||||||
|
break;
|
||||||
|
case 'scale':
|
||||||
|
$msg = wp_save_image( $attachment_id );
|
||||||
|
break;
|
||||||
|
case 'restore':
|
||||||
|
$msg = wp_restore_image( $attachment_id );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
wp_image_editor( $attachment_id, $msg );
|
||||||
|
$html = ob_get_clean();
|
||||||
|
|
||||||
|
if ( ! empty( $msg->error ) ) {
|
||||||
|
wp_send_json_error(
|
||||||
|
array(
|
||||||
|
'message' => $msg,
|
||||||
|
'html' => $html,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
wp_send_json_success(
|
||||||
|
array(
|
||||||
|
'message' => $msg,
|
||||||
|
'html' => $html,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
add_action( 'wp_ajax_image_editor', 'wp_ajax_image_editor' );
|
||||||
|
*/
|
||||||
|
|
||||||
|
?>
|
||||||
2
private
2
private
Submodule private updated: 8dcbef8d75...64c9462106
Reference in New Issue
Block a user