Skip to content

Commit 9b88cfe

Browse files
Check permissions in admin-ajax.php
1 parent d10744c commit 9b88cfe

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed

class.tilda-admin.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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'] )

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Donate link: https://wordpress.org/plugins/tilda-publishing/
44
Tags: blog, bulk, convert, crawl, data, import, importer, migrate, move, posts, publishing, tilda, export
55
Requires at least: 3.0.1
66
Tested up to: 6.2
7-
Stable tag: 0.3.20
7+
Stable tag: 0.3.21
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -62,6 +62,9 @@ A: Please create an issue on the [GitHub page](https://github.com/TildaPublishin
6262

6363
== Changelog ==
6464

65+
= 0.3.21 =
66+
* Check permissions in admin-ajax.php
67+
6568
= 0.3.20 =
6669
* Fix changing JS paths
6770

tilda-wordpress-plugin.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
/*
33
Plugin Name: Tilda Publishing
44
Description: Tilda позволяет делать яркую подачу материала, качественную верстку и эффектную типографику, близкую к журнальной. Каким бы ни был ваш контент — Tilda знает, как его показать. С чего начать: 1) Нажмите ссылку «Активировать» слева от этого описания; 2) <a href="http://www.tilda.cc/" target="_blank">Зарегистрируйтесь</a>, чтобы получить API-ключ; 3) Перейдите на страницу настройки Tilda Publishing и введите свой API-ключ. Читайте подробную инструкцию по подключению.
5-
Version: 0.3.20
5+
Version: 0.3.21
66
Author: Tilda Publishing
77
License: GPLv2 or later
88
Text Domain: api tilda
99
10+
Update 0.3.21 - check permissions in admin-ajax.php
11+
1012
Update 0.3.20 - fix changing JS paths
1113
1214
Update 0.3.19 - fix saving images locally
@@ -122,7 +124,7 @@
122124
exit;
123125
}
124126

125-
define( 'TILDA_VERSION', '0.3.20' );
127+
define( 'TILDA_VERSION', '0.3.21' );
126128
define( 'TILDA_MINIMUM_WP_VERSION', '3.1' );
127129
define( 'TILDA_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
128130
define( 'TILDA_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );

0 commit comments

Comments
 (0)