Changeset 3057511
- Timestamp:
- 03/24/2024 12:12:52 AM (2 years ago)
- Location:
- ai-post-generator
- Files:
-
- 18 edited
-
tags/3.0/functions.php (modified) (1 diff)
-
tags/3.0/inc/insert-head.php (modified) (7 diffs)
-
tags/3.0/js/main.js (modified) (7 diffs)
-
tags/3.1/functions.php (modified) (1 diff)
-
tags/3.1/inc/insert-head.php (modified) (7 diffs)
-
tags/3.1/js/main.js (modified) (7 diffs)
-
tags/3.2/functions.php (modified) (1 diff)
-
tags/3.2/inc/insert-head.php (modified) (7 diffs)
-
tags/3.2/js/main.js (modified) (7 diffs)
-
tags/3.3/functions.php (modified) (1 diff)
-
tags/3.3/inc/insert-head.php (modified) (7 diffs)
-
tags/3.3/js/main.js (modified) (7 diffs)
-
tags/3.4/functions.php (modified) (1 diff)
-
tags/3.4/inc/insert-head.php (modified) (7 diffs)
-
tags/3.4/js/main.js (modified) (7 diffs)
-
trunk/functions.php (modified) (1 diff)
-
trunk/inc/insert-head.php (modified) (7 diffs)
-
trunk/js/main.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ai-post-generator/tags/3.0/functions.php
r2913274 r3057511 2 2 3 3 4 4 if (!function_exists('ai_post_generator_verify_nonce')){ 5 function ai_post_generator_verify_nonce() { 6 if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'ai_post_generator_nonce')) { 7 ai_post_generator_return_json(array('exito' => false, 'error' => 'Verificación de nonce fallida.')); 8 die(); 9 } 10 } 11 } 5 12 6 13 -
ai-post-generator/tags/3.0/inc/insert-head.php
r3056060 r3057511 202 202 function ai_post_generator_get_Posts() 203 203 { 204 ai_post_generator_verify_nonce(); 205 204 206 if (!current_user_can('read_private_posts')) { 205 207 ai_post_generator_return_json(array('exito' => false, 'error' => 'Usuario no autorizado.')); … … 243 245 function ai_post_generator_data_Publish() 244 246 { 247 ai_post_generator_verify_nonce(); 248 245 249 if (!current_user_can('publish_posts')) { 246 250 ai_post_generator_return_json(array('exito' => false, 'error' => 'Usuario no autorizado.')); … … 346 350 function ai_post_generator_data_Preview() 347 351 { 352 ai_post_generator_verify_nonce(); 348 353 349 354 if (!isset($_POST['text']) || !isset($_POST['id'])) { … … 371 376 function ai_post_generator_saveas_Publish() 372 377 { 378 ai_post_generator_verify_nonce(); 373 379 374 380 if (!isset($_POST['id'])) { … … 402 408 function ai_post_generator_delete_Post() 403 409 { 410 ai_post_generator_verify_nonce(); 404 411 405 412 if (!isset($_POST['id'])) { … … 569 576 wp_enqueue_script( 570 577 571 'm y-functions4',578 'main-functions', 572 579 573 580 trailingslashit(AI_POST_GENERATOR_PLUGIN_URL) . "js/main.js", … … 580 587 581 588 ); 589 // Pasar parámetros a JavaScript 590 wp_localize_script('main-functions', 'aiPostGenerator', array( 591 'ajaxurl' => admin_url('admin-ajax.php'), 592 'nonce' => wp_create_nonce('ai_post_generator_nonce') 593 )); 582 594 583 595 //TABLE BOOTSTRAP -
ai-post-generator/tags/3.0/js/main.js
r2913104 r3057511 2357 2357 var concept_table = ""; 2358 2358 $.ajax({ 2359 url : 'admin-ajax.php',2360 type: ' get',2359 url : aiPostGenerator.ajaxurl, 2360 type: 'POST', 2361 2361 dataType: 'json', 2362 2362 data: { 2363 action: 'ai_post_generator_get_Posts' 2363 action: 'ai_post_generator_get_Posts', 2364 nonce: aiPostGenerator.nonce 2364 2365 }, 2365 2366 success: function(data) { … … 2522 2523 function create_post(post){ 2523 2524 $.ajax({ 2524 url : 'admin-ajax.php',2525 url : aiPostGenerator.ajaxurl, 2525 2526 type: 'post', 2526 2527 dataType: 'json', 2527 2528 data: { 2528 action: 'ai_post_generator_data_Publish', title: post.title, text: post.text, type : "draft", im : post.cover, date : post.date 2529 action: 'ai_post_generator_data_Publish', title: post.title, text: post.text, type : "draft", im : post.cover, date : post.date, 2530 nonce: aiPostGenerator.nonce 2529 2531 }, 2530 2532 success: function(data) { … … 2545 2547 if (confirm("Are you sure you want to delete that post?") == true) { 2546 2548 $.ajax({ 2547 url : 'admin-ajax.php',2549 url : aiPostGenerator.ajaxurl, 2548 2550 type: 'post', 2549 2551 dataType: 'json', 2550 2552 data: { 2551 action: 'ai_post_generator_delete_Post', id: post.id 2553 action: 'ai_post_generator_delete_Post', id: post.id, 2554 nonce: aiPostGenerator.nonce 2552 2555 }, 2553 2556 success: function(data) { … … 3789 3792 } 3790 3793 $.ajax({ 3791 url : 'admin-ajax.php',3794 url : aiPostGenerator.ajaxurl, 3792 3795 type: 'post', 3793 3796 dataType: 'json', 3794 3797 data: { 3795 action: 'ai_post_generator_data_Publish', title: title, text: text, type : "draft", im : im 3798 action: 'ai_post_generator_data_Publish', title: title, text: text, type : "draft", im : im, 3799 nonce: aiPostGenerator.nonce 3796 3800 }, 3797 3801 success: function(data) { … … 3828 3832 3829 3833 $.ajax({ 3830 url : 'admin-ajax.php',3834 url : aiPostGenerator.ajaxurl, 3831 3835 type: 'post', 3832 3836 dataType: 'json', 3833 3837 data: { 3834 action: 'ai_post_generator_data_Preview', id: id, text: text 3838 action: 'ai_post_generator_data_Preview', id: id, text: text, 3839 nonce: aiPostGenerator.nonce 3835 3840 }, 3836 3841 success: function(data) { … … 3860 3865 3861 3866 $.ajax({ 3862 url : 'admin-ajax.php',3867 url : aiPostGenerator.ajaxurl, 3863 3868 3864 3869 type: 'post', … … 3868 3873 data: { 3869 3874 3870 action: 'ai_post_generator_saveas_Publish', id: id, text: text 3875 action: 'ai_post_generator_saveas_Publish', id: id, text: text, 3876 nonce: aiPostGenerator.nonce 3871 3877 3872 3878 }, -
ai-post-generator/tags/3.1/functions.php
r2913278 r3057511 2 2 3 3 4 4 if (!function_exists('ai_post_generator_verify_nonce')){ 5 function ai_post_generator_verify_nonce() { 6 if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'ai_post_generator_nonce')) { 7 ai_post_generator_return_json(array('exito' => false, 'error' => 'Verificación de nonce fallida.')); 8 die(); 9 } 10 } 11 } 5 12 6 13 -
ai-post-generator/tags/3.1/inc/insert-head.php
r3056060 r3057511 205 205 function ai_post_generator_get_Posts() 206 206 { 207 ai_post_generator_verify_nonce(); 208 207 209 if (!current_user_can('read_private_posts')) { 208 210 ai_post_generator_return_json(array('exito' => false, 'error' => 'Usuario no autorizado.')); … … 246 248 function ai_post_generator_data_Publish() 247 249 { 250 ai_post_generator_verify_nonce(); 251 248 252 if (!current_user_can('publish_posts')) { 249 253 ai_post_generator_return_json(array('exito' => false, 'error' => 'Usuario no autorizado.')); … … 349 353 function ai_post_generator_data_Preview() 350 354 { 355 ai_post_generator_verify_nonce(); 356 351 357 if (!current_user_can('read_private_posts')) { 352 358 ai_post_generator_return_json(array('exito' => false, 'error' => 'Usuario no autorizado.')); … … 378 384 function ai_post_generator_saveas_Publish() 379 385 { 386 ai_post_generator_verify_nonce(); 387 380 388 if (!current_user_can('publish_posts')) { 381 389 ai_post_generator_return_json(array('exito' => false, 'error' => 'Usuario no autorizado.')); … … 413 421 function ai_post_generator_delete_Post() 414 422 { 423 ai_post_generator_verify_nonce(); 424 415 425 if (!current_user_can('delete_posts')) { 416 426 ai_post_generator_return_json(array('exito' => false, 'error' => 'Usuario no autorizado.')); … … 606 616 wp_enqueue_script( 607 617 608 'm y-functions4',618 'main-functions', 609 619 610 620 trailingslashit(AI_POST_GENERATOR_PLUGIN_URL) . "js/main.js", … … 617 627 618 628 ); 629 // Pasar parámetros a JavaScript 630 wp_localize_script('main-functions', 'aiPostGenerator', array( 631 'ajaxurl' => admin_url('admin-ajax.php'), 632 'nonce' => wp_create_nonce('ai_post_generator_nonce') 633 )); 619 634 620 635 //DATATABLE -
ai-post-generator/tags/3.1/js/main.js
r2913278 r3057511 2357 2357 var concept_table = ""; 2358 2358 $.ajax({ 2359 url : 'admin-ajax.php',2360 type: ' get',2359 url : aiPostGenerator.ajaxurl, 2360 type: 'POST', 2361 2361 dataType: 'json', 2362 2362 data: { 2363 action: 'ai_post_generator_get_Posts' 2363 action: 'ai_post_generator_get_Posts', 2364 nonce: aiPostGenerator.nonce 2364 2365 }, 2365 2366 success: function(data) { … … 2522 2523 function create_post(post){ 2523 2524 $.ajax({ 2524 url : 'admin-ajax.php',2525 url : aiPostGenerator.ajaxurl, 2525 2526 type: 'post', 2526 2527 dataType: 'json', 2527 2528 data: { 2528 action: 'ai_post_generator_data_Publish', title: post.title, text: post.text, type : "draft", im : post.cover, date : post.date 2529 action: 'ai_post_generator_data_Publish', title: post.title, text: post.text, type : "draft", im : post.cover, date : post.date, 2530 nonce: aiPostGenerator.nonce 2529 2531 }, 2530 2532 success: function(data) { … … 2545 2547 if (confirm("Are you sure you want to delete that post?") == true) { 2546 2548 $.ajax({ 2547 url : 'admin-ajax.php',2549 url : aiPostGenerator.ajaxurl, 2548 2550 type: 'post', 2549 2551 dataType: 'json', 2550 2552 data: { 2551 action: 'ai_post_generator_delete_Post', id: post.id 2553 action: 'ai_post_generator_delete_Post', id: post.id, 2554 nonce: aiPostGenerator.nonce 2552 2555 }, 2553 2556 success: function(data) { … … 3789 3792 } 3790 3793 $.ajax({ 3791 url : 'admin-ajax.php',3794 url : aiPostGenerator.ajaxurl, 3792 3795 type: 'post', 3793 3796 dataType: 'json', 3794 3797 data: { 3795 action: 'ai_post_generator_data_Publish', title: title, text: text, type : "draft", im : im 3798 action: 'ai_post_generator_data_Publish', title: title, text: text, type : "draft", im : im, 3799 nonce: aiPostGenerator.nonce 3796 3800 }, 3797 3801 success: function(data) { … … 3828 3832 3829 3833 $.ajax({ 3830 url : 'admin-ajax.php',3834 url : aiPostGenerator.ajaxurl, 3831 3835 type: 'post', 3832 3836 dataType: 'json', 3833 3837 data: { 3834 action: 'ai_post_generator_data_Preview', id: id, text: text 3838 action: 'ai_post_generator_data_Preview', id: id, text: text, 3839 nonce: aiPostGenerator.nonce 3835 3840 }, 3836 3841 success: function(data) { … … 3860 3865 3861 3866 $.ajax({ 3862 url : 'admin-ajax.php',3867 url : aiPostGenerator.ajaxurl, 3863 3868 3864 3869 type: 'post', … … 3868 3873 data: { 3869 3874 3870 action: 'ai_post_generator_saveas_Publish', id: id, text: text 3875 action: 'ai_post_generator_saveas_Publish', id: id, text: text, 3876 nonce: aiPostGenerator.nonce 3871 3877 3872 3878 }, -
ai-post-generator/tags/3.2/functions.php
r2929202 r3057511 3 3 4 4 5 5 if (!function_exists('ai_post_generator_verify_nonce')){ 6 function ai_post_generator_verify_nonce() { 7 if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'ai_post_generator_nonce')) { 8 ai_post_generator_return_json(array('exito' => false, 'error' => 'Verificación de nonce fallida.')); 9 die(); 10 } 11 } 12 } 6 13 7 14 if (!function_exists('ai_post_generator_return_json_2')){ -
ai-post-generator/tags/3.2/inc/insert-head.php
r3056060 r3057511 205 205 function ai_post_generator_get_Posts() 206 206 { 207 ai_post_generator_verify_nonce(); 208 207 209 if (!current_user_can('read_private_posts')) { 208 210 ai_post_generator_return_json(array('exito' => false, 'error' => 'Usuario no autorizado.')); … … 246 248 function ai_post_generator_data_Publish() 247 249 { 250 ai_post_generator_verify_nonce(); 251 248 252 if (!current_user_can('publish_posts')) { 249 253 ai_post_generator_return_json(array('exito' => false, 'error' => 'Usuario no autorizado.')); … … 349 353 function ai_post_generator_data_Preview() 350 354 { 355 ai_post_generator_verify_nonce(); 356 351 357 if (!current_user_can('read_private_posts')) { 352 358 ai_post_generator_return_json(array('exito' => false, 'error' => 'Usuario no autorizado.')); … … 378 384 function ai_post_generator_saveas_Publish() 379 385 { 386 ai_post_generator_verify_nonce(); 387 380 388 if (!current_user_can('publish_posts')) { 381 389 ai_post_generator_return_json(array('exito' => false, 'error' => 'Usuario no autorizado.')); … … 413 421 function ai_post_generator_delete_Post() 414 422 { 423 ai_post_generator_verify_nonce(); 424 415 425 if (!current_user_can('delete_posts')) { 416 426 ai_post_generator_return_json(array('exito' => false, 'error' => 'Usuario no autorizado.')); … … 619 629 wp_enqueue_script( 620 630 621 'm y-functions4',631 'main-functions', 622 632 623 633 trailingslashit(AI_POST_GENERATOR_PLUGIN_URL) . "js/main.js", … … 630 640 631 641 ); 642 // Pasar parámetros a JavaScript 643 wp_localize_script('main-functions', 'aiPostGenerator', array( 644 'ajaxurl' => admin_url('admin-ajax.php'), 645 'nonce' => wp_create_nonce('ai_post_generator_nonce') 646 )); 632 647 633 648 //DATATABLE -
ai-post-generator/tags/3.2/js/main.js
r2929202 r3057511 2357 2357 var concept_table = ""; 2358 2358 $.ajax({ 2359 url : 'admin-ajax.php',2360 type: ' get',2359 url : aiPostGenerator.ajaxurl, 2360 type: 'POST', 2361 2361 dataType: 'json', 2362 2362 data: { 2363 action: 'ai_post_generator_get_Posts' 2363 action: 'ai_post_generator_get_Posts', 2364 nonce: aiPostGenerator.nonce 2364 2365 }, 2365 2366 success: function(data) { … … 2522 2523 function create_post(post){ 2523 2524 $.ajax({ 2524 url : 'admin-ajax.php',2525 url : aiPostGenerator.ajaxurl, 2525 2526 type: 'post', 2526 2527 dataType: 'json', 2527 2528 data: { 2528 action: 'ai_post_generator_data_Publish', title: post.title, text: post.text, type : "draft", im : post.cover, date : post.date 2529 action: 'ai_post_generator_data_Publish', title: post.title, text: post.text, type : "draft", im : post.cover, date : post.date, 2530 nonce: aiPostGenerator.nonce 2529 2531 }, 2530 2532 success: function(data) { … … 2545 2547 if (confirm("Are you sure you want to delete that post?") == true) { 2546 2548 $.ajax({ 2547 url : 'admin-ajax.php',2549 url : aiPostGenerator.ajaxurl, 2548 2550 type: 'post', 2549 2551 dataType: 'json', 2550 2552 data: { 2551 action: 'ai_post_generator_delete_Post', id: post.id 2553 action: 'ai_post_generator_delete_Post', id: post.id, 2554 nonce: aiPostGenerator.nonce 2552 2555 }, 2553 2556 success: function(data) { … … 3789 3792 } 3790 3793 $.ajax({ 3791 url : 'admin-ajax.php',3794 url : aiPostGenerator.ajaxurl, 3792 3795 type: 'post', 3793 3796 dataType: 'json', 3794 3797 data: { 3795 action: 'ai_post_generator_data_Publish', title: title, text: text, type : "draft", im : im 3798 action: 'ai_post_generator_data_Publish', title: title, text: text, type : "draft", im : im, 3799 nonce: aiPostGenerator.nonce 3796 3800 }, 3797 3801 success: function(data) { … … 3828 3832 3829 3833 $.ajax({ 3830 url : 'admin-ajax.php',3834 url : aiPostGenerator.ajaxurl, 3831 3835 type: 'post', 3832 3836 dataType: 'json', 3833 3837 data: { 3834 action: 'ai_post_generator_data_Preview', id: id, text: text 3838 action: 'ai_post_generator_data_Preview', id: id, text: text, 3839 nonce: aiPostGenerator.nonce 3835 3840 }, 3836 3841 success: function(data) { … … 3860 3865 3861 3866 $.ajax({ 3862 url : 'admin-ajax.php',3867 url : aiPostGenerator.ajaxurl, 3863 3868 3864 3869 type: 'post', … … 3868 3873 data: { 3869 3874 3870 action: 'ai_post_generator_saveas_Publish', id: id, text: text 3875 action: 'ai_post_generator_saveas_Publish', id: id, text: text, 3876 nonce: aiPostGenerator.nonce 3871 3877 3872 3878 }, -
ai-post-generator/tags/3.3/functions.php
r3015504 r3057511 3 3 4 4 5 5 if (!function_exists('ai_post_generator_verify_nonce')){ 6 function ai_post_generator_verify_nonce() { 7 if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'ai_post_generator_nonce')) { 8 ai_post_generator_return_json(array('exito' => false, 'error' => 'Verificación de nonce fallida.')); 9 die(); 10 } 11 } 12 } 6 13 7 14 if (!function_exists('ai_post_generator_return_json_2')){ -
ai-post-generator/tags/3.3/inc/insert-head.php
r3056060 r3057511 213 213 function ai_post_generator_get_Posts() 214 214 { 215 ai_post_generator_verify_nonce(); 216 215 217 if (!current_user_can('read_private_posts')) { 216 218 ai_post_generator_return_json(array('exito' => false, 'error' => 'Usuario no autorizado.')); … … 254 256 function ai_post_generator_data_Publish() 255 257 { 258 ai_post_generator_verify_nonce(); 259 256 260 if (!current_user_can('publish_posts')) { 257 261 ai_post_generator_return_json(array('exito' => false, 'error' => 'Usuario no autorizado.')); … … 357 361 function ai_post_generator_data_Preview() 358 362 { 363 ai_post_generator_verify_nonce(); 364 359 365 // Comprobar si el usuario tiene permiso para publicar posts 360 366 if (!current_user_can('read_private_posts')) { … … 387 393 function ai_post_generator_saveas_Publish() 388 394 { 395 ai_post_generator_verify_nonce(); 389 396 390 397 // Comprobar si el usuario tiene permiso para publicar posts … … 423 430 function ai_post_generator_delete_Post() 424 431 { 432 ai_post_generator_verify_nonce(); 433 425 434 // Comprobar si el usuario tiene permiso para publicar posts 426 435 if (!current_user_can('delete_posts')) { … … 630 639 wp_enqueue_script( 631 640 632 'm y-functions4',641 'main-functions', 633 642 634 643 trailingslashit(AI_POST_GENERATOR_PLUGIN_URL) . "js/main.js", … … 672 681 673 682 ); 683 // Pasar parámetros a JavaScript 684 wp_localize_script('main-functions', 'aiPostGenerator', array( 685 'ajaxurl' => admin_url('admin-ajax.php'), 686 'nonce' => wp_create_nonce('ai_post_generator_nonce') 687 )); 674 688 675 689 } -
ai-post-generator/tags/3.3/js/main.js
r3015504 r3057511 2357 2357 var concept_table = ""; 2358 2358 $.ajax({ 2359 url : 'admin-ajax.php',2360 type: ' get',2359 url : aiPostGenerator.ajaxurl, 2360 type: 'POST', 2361 2361 dataType: 'json', 2362 2362 data: { 2363 action: 'ai_post_generator_get_Posts' 2363 action: 'ai_post_generator_get_Posts', 2364 nonce: aiPostGenerator.nonce 2364 2365 }, 2365 2366 success: function(data) { … … 2522 2523 function create_post(post){ 2523 2524 $.ajax({ 2524 url : 'admin-ajax.php',2525 url : aiPostGenerator.ajaxurl, 2525 2526 type: 'post', 2526 2527 dataType: 'json', 2527 2528 data: { 2528 action: 'ai_post_generator_data_Publish', title: post.title, text: post.text, type : "draft", im : post.cover, date : post.date 2529 action: 'ai_post_generator_data_Publish', title: post.title, text: post.text, type : "draft", im : post.cover, date : post.date, 2530 nonce: aiPostGenerator.nonce 2529 2531 }, 2530 2532 success: function(data) { … … 2545 2547 if (confirm("Are you sure you want to delete that post?") == true) { 2546 2548 $.ajax({ 2547 url : 'admin-ajax.php',2549 url : aiPostGenerator.ajaxurl, 2548 2550 type: 'post', 2549 2551 dataType: 'json', 2550 2552 data: { 2551 action: 'ai_post_generator_delete_Post', id: post.id 2553 action: 'ai_post_generator_delete_Post', 2554 nonce: aiPostGenerator.nonce, 2555 id: post.id 2552 2556 }, 2553 2557 success: function(data) { … … 3789 3793 } 3790 3794 $.ajax({ 3791 url : 'admin-ajax.php',3795 url : aiPostGenerator.ajaxurl, 3792 3796 type: 'post', 3793 3797 dataType: 'json', 3794 3798 data: { 3795 action: 'ai_post_generator_data_Publish', title: title, text: text, type : "draft", im : im 3799 action: 'ai_post_generator_data_Publish', title: title, text: text, type : "draft", im : im, 3800 nonce: aiPostGenerator.nonce 3796 3801 }, 3797 3802 success: function(data) { … … 3828 3833 3829 3834 $.ajax({ 3830 url : 'admin-ajax.php',3835 url : aiPostGenerator.ajaxurl, 3831 3836 type: 'post', 3832 3837 dataType: 'json', 3833 3838 data: { 3834 action: 'ai_post_generator_data_Preview', id: id, text: text 3839 action: 'ai_post_generator_data_Preview', id: id, text: text, 3840 nonce: aiPostGenerator.nonce 3835 3841 }, 3836 3842 success: function(data) { … … 3860 3866 3861 3867 $.ajax({ 3862 url : 'admin-ajax.php',3868 url : aiPostGenerator.ajaxurl, 3863 3869 3864 3870 type: 'post', … … 3868 3874 data: { 3869 3875 3870 action: 'ai_post_generator_saveas_Publish', id: id, text: text 3876 action: 'ai_post_generator_saveas_Publish', id: id, text: text, 3877 nonce: aiPostGenerator.nonce 3871 3878 3872 3879 }, -
ai-post-generator/tags/3.4/functions.php
r3056020 r3057511 3 3 4 4 5 5 if (!function_exists('ai_post_generator_verify_nonce')){ 6 function ai_post_generator_verify_nonce() { 7 if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'ai_post_generator_nonce')) { 8 ai_post_generator_return_json(array('exito' => false, 'error' => 'Verificación de nonce fallida.')); 9 die(); 10 } 11 } 12 } 6 13 7 14 if (!function_exists('ai_post_generator_return_json_2')){ -
ai-post-generator/tags/3.4/inc/insert-head.php
r3056020 r3057511 213 213 function ai_post_generator_get_Posts() 214 214 { 215 ai_post_generator_verify_nonce(); 216 215 217 if (!current_user_can('read_private_posts')) { 216 218 ai_post_generator_return_json(array('exito' => false, 'error' => 'Usuario no autorizado.')); … … 254 256 function ai_post_generator_data_Publish() 255 257 { 258 ai_post_generator_verify_nonce(); 259 256 260 if (!current_user_can('publish_posts')) { 257 261 ai_post_generator_return_json(array('exito' => false, 'error' => 'Usuario no autorizado.')); … … 357 361 function ai_post_generator_data_Preview() 358 362 { 363 ai_post_generator_verify_nonce(); 364 359 365 // Comprobar si el usuario tiene permiso para publicar posts 360 366 if (!current_user_can('read_private_posts')) { … … 387 393 function ai_post_generator_saveas_Publish() 388 394 { 395 ai_post_generator_verify_nonce(); 389 396 390 397 // Comprobar si el usuario tiene permiso para publicar posts … … 423 430 function ai_post_generator_delete_Post() 424 431 { 432 ai_post_generator_verify_nonce(); 433 425 434 // Comprobar si el usuario tiene permiso para publicar posts 426 435 if (!current_user_can('delete_posts')) { … … 630 639 wp_enqueue_script( 631 640 632 'm y-functions4',641 'main-functions', 633 642 634 643 trailingslashit(AI_POST_GENERATOR_PLUGIN_URL) . "js/main.js", … … 672 681 673 682 ); 683 // Pasar parámetros a JavaScript 684 wp_localize_script('main-functions', 'aiPostGenerator', array( 685 'ajaxurl' => admin_url('admin-ajax.php'), 686 'nonce' => wp_create_nonce('ai_post_generator_nonce') 687 )); 674 688 675 689 } -
ai-post-generator/tags/3.4/js/main.js
r3056020 r3057511 2357 2357 var concept_table = ""; 2358 2358 $.ajax({ 2359 url : 'admin-ajax.php',2360 type: ' get',2359 url : aiPostGenerator.ajaxurl, 2360 type: 'POST', 2361 2361 dataType: 'json', 2362 2362 data: { 2363 action: 'ai_post_generator_get_Posts' 2363 action: 'ai_post_generator_get_Posts', 2364 nonce: aiPostGenerator.nonce 2364 2365 }, 2365 2366 success: function(data) { … … 2522 2523 function create_post(post){ 2523 2524 $.ajax({ 2524 url : 'admin-ajax.php',2525 url : aiPostGenerator.ajaxurl, 2525 2526 type: 'post', 2526 2527 dataType: 'json', 2527 2528 data: { 2528 action: 'ai_post_generator_data_Publish', title: post.title, text: post.text, type : "draft", im : post.cover, date : post.date 2529 action: 'ai_post_generator_data_Publish', title: post.title, text: post.text, type : "draft", im : post.cover, date : post.date, 2530 nonce: aiPostGenerator.nonce 2529 2531 }, 2530 2532 success: function(data) { … … 2545 2547 if (confirm("Are you sure you want to delete that post?") == true) { 2546 2548 $.ajax({ 2547 url : 'admin-ajax.php',2549 url : aiPostGenerator.ajaxurl, 2548 2550 type: 'post', 2549 2551 dataType: 'json', 2550 2552 data: { 2551 action: 'ai_post_generator_delete_Post', id: post.id 2553 action: 'ai_post_generator_delete_Post', 2554 nonce: aiPostGenerator.nonce, 2555 id: post.id 2552 2556 }, 2553 2557 success: function(data) { … … 3789 3793 } 3790 3794 $.ajax({ 3791 url : 'admin-ajax.php',3795 url : aiPostGenerator.ajaxurl, 3792 3796 type: 'post', 3793 3797 dataType: 'json', 3794 3798 data: { 3795 action: 'ai_post_generator_data_Publish', title: title, text: text, type : "draft", im : im 3799 action: 'ai_post_generator_data_Publish', title: title, text: text, type : "draft", im : im, 3800 nonce: aiPostGenerator.nonce 3796 3801 }, 3797 3802 success: function(data) { … … 3828 3833 3829 3834 $.ajax({ 3830 url : 'admin-ajax.php',3835 url : aiPostGenerator.ajaxurl, 3831 3836 type: 'post', 3832 3837 dataType: 'json', 3833 3838 data: { 3834 action: 'ai_post_generator_data_Preview', id: id, text: text 3839 action: 'ai_post_generator_data_Preview', id: id, text: text, 3840 nonce: aiPostGenerator.nonce 3835 3841 }, 3836 3842 success: function(data) { … … 3860 3866 3861 3867 $.ajax({ 3862 url : 'admin-ajax.php',3868 url : aiPostGenerator.ajaxurl, 3863 3869 3864 3870 type: 'post', … … 3868 3874 data: { 3869 3875 3870 action: 'ai_post_generator_saveas_Publish', id: id, text: text 3876 action: 'ai_post_generator_saveas_Publish', id: id, text: text, 3877 nonce: aiPostGenerator.nonce 3871 3878 3872 3879 }, -
ai-post-generator/trunk/functions.php
r2913274 r3057511 688 688 689 689 690 690 if (!function_exists('ai_post_generator_verify_nonce')){ 691 function ai_post_generator_verify_nonce() { 692 if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'ai_post_generator_nonce')) { 693 ai_post_generator_return_json(array('exito' => false, 'error' => 'Verificación de nonce fallida.')); 694 die(); 695 } 696 } 697 } 691 698 692 699 if (!function_exists('ai_post_generator_download_img')){ -
ai-post-generator/trunk/inc/insert-head.php
r3056020 r3057511 213 213 function ai_post_generator_get_Posts() 214 214 { 215 ai_post_generator_verify_nonce(); 216 215 217 if (!current_user_can('read_private_posts')) { 216 218 ai_post_generator_return_json(array('exito' => false, 'error' => 'Usuario no autorizado.')); … … 254 256 function ai_post_generator_data_Publish() 255 257 { 258 ai_post_generator_verify_nonce(); 259 256 260 if (!current_user_can('publish_posts')) { 257 261 ai_post_generator_return_json(array('exito' => false, 'error' => 'Usuario no autorizado.')); … … 357 361 function ai_post_generator_data_Preview() 358 362 { 363 ai_post_generator_verify_nonce(); 364 359 365 // Comprobar si el usuario tiene permiso para publicar posts 360 366 if (!current_user_can('read_private_posts')) { … … 387 393 function ai_post_generator_saveas_Publish() 388 394 { 395 ai_post_generator_verify_nonce(); 389 396 390 397 // Comprobar si el usuario tiene permiso para publicar posts … … 423 430 function ai_post_generator_delete_Post() 424 431 { 432 ai_post_generator_verify_nonce(); 433 425 434 // Comprobar si el usuario tiene permiso para publicar posts 426 435 if (!current_user_can('delete_posts')) { … … 630 639 wp_enqueue_script( 631 640 632 'm y-functions4',641 'main-functions', 633 642 634 643 trailingslashit(AI_POST_GENERATOR_PLUGIN_URL) . "js/main.js", … … 672 681 673 682 ); 683 // Pasar parámetros a JavaScript 684 wp_localize_script('main-functions', 'aiPostGenerator', array( 685 'ajaxurl' => admin_url('admin-ajax.php'), 686 'nonce' => wp_create_nonce('ai_post_generator_nonce') 687 )); 674 688 675 689 } -
ai-post-generator/trunk/js/main.js
r2895022 r3057511 2357 2357 var concept_table = ""; 2358 2358 $.ajax({ 2359 url : 'admin-ajax.php',2360 type: ' get',2359 url : aiPostGenerator.ajaxurl, 2360 type: 'POST', 2361 2361 dataType: 'json', 2362 2362 data: { 2363 action: 'ai_post_generator_get_Posts' 2363 action: 'ai_post_generator_get_Posts', 2364 nonce: aiPostGenerator.nonce 2364 2365 }, 2365 2366 success: function(data) { … … 2522 2523 function create_post(post){ 2523 2524 $.ajax({ 2524 url : 'admin-ajax.php',2525 url : aiPostGenerator.ajaxurl, 2525 2526 type: 'post', 2526 2527 dataType: 'json', 2527 2528 data: { 2528 action: 'ai_post_generator_data_Publish', title: post.title, text: post.text, type : "draft", im : post.cover, date : post.date 2529 action: 'ai_post_generator_data_Publish', title: post.title, text: post.text, type : "draft", im : post.cover, date : post.date, 2530 nonce: aiPostGenerator.nonce 2529 2531 }, 2530 2532 success: function(data) { … … 2545 2547 if (confirm("Are you sure you want to delete that post?") == true) { 2546 2548 $.ajax({ 2547 url : 'admin-ajax.php',2549 url : aiPostGenerator.ajaxurl, 2548 2550 type: 'post', 2549 2551 dataType: 'json', 2550 2552 data: { 2551 action: 'ai_post_generator_delete_Post', id: post.id 2553 action: 'ai_post_generator_delete_Post', 2554 nonce: aiPostGenerator.nonce, 2555 id: post.id 2552 2556 }, 2553 2557 success: function(data) { … … 3789 3793 } 3790 3794 $.ajax({ 3791 url : 'admin-ajax.php',3795 url : aiPostGenerator.ajaxurl, 3792 3796 type: 'post', 3793 3797 dataType: 'json', 3794 3798 data: { 3795 action: 'ai_post_generator_data_Publish', title: title, text: text, type : "draft", im : im 3799 action: 'ai_post_generator_data_Publish', title: title, text: text, type : "draft", im : im, 3800 nonce: aiPostGenerator.nonce 3796 3801 }, 3797 3802 success: function(data) { … … 3828 3833 3829 3834 $.ajax({ 3830 url : 'admin-ajax.php',3835 url : aiPostGenerator.ajaxurl, 3831 3836 type: 'post', 3832 3837 dataType: 'json', 3833 3838 data: { 3834 action: 'ai_post_generator_data_Preview', id: id, text: text 3839 action: 'ai_post_generator_data_Preview', id: id, text: text, 3840 nonce: aiPostGenerator.nonce 3835 3841 }, 3836 3842 success: function(data) { … … 3860 3866 3861 3867 $.ajax({ 3862 url : 'admin-ajax.php',3868 url : aiPostGenerator.ajaxurl, 3863 3869 3864 3870 type: 'post', … … 3868 3874 data: { 3869 3875 3870 action: 'ai_post_generator_saveas_Publish', id: id, text: text 3876 action: 'ai_post_generator_saveas_Publish', id: id, text: text, 3877 nonce: aiPostGenerator.nonce 3871 3878 3872 3879 },
Note: See TracChangeset
for help on using the changeset viewer.