Begining to code the Ajax action

This commit is contained in:
vdv committed 2025-03-27 16:35:50 +01:00
1 parent 7d8beefebf
commit 338b69d4f1
4 files changed
+125 -2

No files matched your search

+22 -2
View File
@@ -32,16 +32,36 @@ add_action('manage_media_custom_column', 'manage_custom_columns', 10, 2);
function manage_custom_columns ($column_key, $post_id) {
if ($column_key == 'wp-pdf-helper') {
$checked = (get_post_meta($post_id, 'wpdfh.print', true) == '') ? '' : 'checked';
echo "<input type='checkbox' name='Print' value='always' $checked />";
error_log("PHP: \$column_key: $column_key, \$post_id: $post_id, \$is_printable: $is_printable.", 0);
echo "<input type='checkbox' class='wpdfh_print_checkbox' name='Print' data-post_id='$post_id' $checked />";
// error_log("PHP: \$column_key: $column_key, \$post_id: $post_id, \$is_printable: $is_printable.", 0);
}
}
add_action('admin_enqueue_scripts', 'wpdfh_enqueue_admin_scripts');
function wpdfh_enqueue_admin_scripts() {
wp_enqueue_style( 'wpdfh-admin', plugin_dir_url( __FILE__ ) . 'assets/wp-pdf-helper-admin.css' );
wp_register_script(
'wpdfh-ajax-admin',
plugins_url('assets/jquery.ajax.js', __FILE__),
array(),
false,
true
);
wp_enqueue_script( 'wpdfh-ajax-admin' );
wp_localize_script(
'wpdfh-ajax-admin',
'wpdfh_ajax_object',
array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) )
);
}
add_action( "wp_ajax_wpdfh_set_print_metadata", "wpdfh_set_print_metadata" );
function wpdfh_set_print_metadata(){
error_log("PHP: wpdfh_set_print_metadata", 0);
wp_send_json_success();
}
if ( ! array_key_exists('print', $_GET)) {
return;
}