@@ -454,6 +454,10 @@ public static function delete_key( $key_id ) {
454454 * Handle request to wp-ajax.php with action: add_new_key
455455 */
456456 public static function ajax_add_new_key () {
457+ if ( ! current_user_can ( 'level_7 ' ) ) {
458+ wp_die ( '<p> ' . __ ( 'You need a higher level of permission. ' ) . '<p> ' , 403 );
459+ }
460+
457461 $ request = Tilda_Admin::options_sanitize ( $ _POST );
458462 $ defaults = [
459463 'store_html_only ' => true ,
@@ -509,6 +513,10 @@ public static function ajax_add_new_key() {
509513 * Delete key and all assigned projects
510514 */
511515 public static function ajax_delete_key () {
516+ if ( ! current_user_can ( 'level_7 ' ) ) {
517+ wp_die ( '<p> ' . __ ( 'You need a higher level of permission. ' ) . '<p> ' , 403 );
518+ }
519+
512520 $ request = Tilda_Admin::options_sanitize ( $ _GET );
513521
514522 if ( ! isset ( $ request ['id ' ] ) ) {
@@ -527,6 +535,10 @@ public static function ajax_delete_key() {
527535 * Update minor parameters for dedicated key
528536 */
529537 public static function ajax_update_key () {
538+ if ( ! current_user_can ( 'level_7 ' ) ) {
539+ wp_die ( '<p> ' . __ ( 'You need a higher level of permission. ' ) . '<p> ' , 403 );
540+ }
541+
530542 $ request = Tilda_Admin::options_sanitize ( $ _GET );
531543
532544 if ( ! isset ( $ request ['id ' ] ) ) {
@@ -552,6 +564,10 @@ public static function ajax_update_key() {
552564 * Refetch projects and pages from API and save it to the DB
553565 */
554566 public static function ajax_refresh_key () {
567+ if ( ! current_user_can ( 'level_7 ' ) ) {
568+ wp_die ( '<p> ' . __ ( 'You need a higher level of permission. ' ) . '<p> ' , 403 );
569+ }
570+
555571 $ request = Tilda_Admin::options_sanitize ( $ _GET );
556572
557573 if ( empty ( $ request ['id ' ] ) ) {
@@ -585,6 +601,10 @@ public static function ajax_refresh_key() {
585601 * Handle request to wp-ajax.php with action: get_projects
586602 */
587603 public static function ajax_get_projects () {
604+ if ( ! current_user_can ( 'level_7 ' ) ) {
605+ wp_die ( '<p> ' . __ ( 'You need a higher level of permission. ' ) . '<p> ' , 403 );
606+ }
607+
588608 $ projects = Tilda::get_local_projects ();
589609 if ( empty ( $ projects ) ) {
590610 $ projects = [];
@@ -596,6 +616,10 @@ public static function ajax_get_projects() {
596616 * Handle request to wp-ajax.php with action: update_project
597617 */
598618 public static function ajax_update_project () {
619+ if ( ! current_user_can ( 'level_7 ' ) ) {
620+ wp_die ( '<p> ' . __ ( 'You need a higher level of permission. ' ) . '<p> ' , 403 );
621+ }
622+
599623 $ request = Tilda_Admin::project_sanitize ( $ _POST );
600624
601625 if ( ! isset ( $ request ['id ' ] ) ) {
@@ -618,13 +642,21 @@ public static function ajax_update_project() {
618642 * Handle request to wp-ajax.php with action: get_keys
619643 */
620644 public static function ajax_get_keys () {
645+ if ( ! current_user_can ( 'level_7 ' ) ) {
646+ wp_die ( '<p> ' . __ ( 'You need a higher level of permission. ' ) . '<p> ' , 403 );
647+ }
648+
621649 wp_send_json ( Tilda::get_local_keys (), 200 );
622650 }
623651
624652 /**
625653 * Handle request to wp-ajax.php with action: update_common_settings
626654 */
627655 public static function ajax_update_common_settings () {
656+ if ( ! current_user_can ( 'level_7 ' ) ) {
657+ wp_die ( '<p> ' . __ ( 'You need a higher level of permission. ' ) . '<p> ' , 403 );
658+ }
659+
628660 $ options = get_option ( Tilda_Admin::OPTION_OPTIONS );
629661 $ request = Tilda_Admin::options_sanitize ( $ _POST );
630662
@@ -1307,6 +1339,10 @@ public static function export_tilda_page( $page_id, $project_id, $post_id ) {
13071339 *
13081340 */
13091341 public static function ajax_sync () {
1342+ if ( ! current_user_can ( 'level_7 ' ) ) {
1343+ wp_die ( '<p> ' . __ ( 'You need a higher level of permission. ' ) . '<p> ' , 403 );
1344+ }
1345+
13101346 $ arResult = [];
13111347 if ( empty ( $ _REQUEST ['page_id ' ] ) || empty ( $ _REQUEST ['project_id ' ] ) || empty ( $ _REQUEST ['post_id ' ] ) ) {
13121348 $ arResult ['error ' ] = __ ( 'Bad request line. Missing parameter: projectid ' , 'tilda ' );
@@ -1355,6 +1391,10 @@ public static function ajax_sync() {
13551391 *
13561392 */
13571393 public static function ajax_export_file () {
1394+ if ( ! current_user_can ( 'level_7 ' ) ) {
1395+ wp_die ( '<p> ' . __ ( 'You need a higher level of permission. ' ) . '<p> ' , 403 );
1396+ }
1397+
13581398 if ( empty ( self ::$ ts_start_plugin ) ) {
13591399 self ::$ ts_start_plugin = time ();
13601400 }
@@ -1435,6 +1475,10 @@ public static function ajax_export_file() {
14351475 }
14361476
14371477 public static function ajax_switcher_status () {
1478+ if ( ! current_user_can ( 'level_7 ' ) ) {
1479+ wp_die ( '<p> ' . __ ( 'You need a higher level of permission. ' ) . '<p> ' , 403 );
1480+ }
1481+
14381482 if (
14391483 empty ( $ _REQUEST ['post_id ' ] )
14401484 || empty ( $ _REQUEST ['tilda_status ' ] )
0 commit comments