@@ -41,12 +41,12 @@ discard block |
||
| 41 | 41 | * class-wp-rest-attachments-controller.php calls the action with $attachment as array, and also calls parent::update_item(), |
| 42 | 42 | * -> parent class is class-wp-rest-posts-controller.php, that also calls the action, but with $attachment as type WP_Post |
| 43 | 43 | */ |
| 44 | - if (! $postObj instanceof \WP_Post) { |
|
| 44 | + if ( ! $postObj instanceof \WP_Post) { |
|
| 45 | 45 | return; |
| 46 | 46 | } |
| 47 | 47 | $_POST['post_type'] = $postObj->post_type; |
| 48 | 48 | // save all the data in an anonymous function |
| 49 | - $trigger_func = function ($response, $handler, $request) use ($postObj, $update) { |
|
| 49 | + $trigger_func = function($response, $handler, $request) use ($postObj, $update) { |
|
| 50 | 50 | // call the internal save_post after all postmeta is written |
| 51 | 51 | $this->save_post($postObj->ID, $postObj, $update); |
| 52 | 52 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | do_action('krn_flattable_pre_delete_' . $postObj->post_type, $postObj); |
| 74 | 74 | $customCols = apply_filters('krn_flattable_columns_' . $postObj->post_type, [], $postObj); |
| 75 | 75 | //check if there are any other than required columns, we dont need an "empty" table |
| 76 | - if(empty($customCols)) { |
|
| 76 | + if (empty($customCols)) { |
|
| 77 | 77 | return; |
| 78 | 78 | } |
| 79 | 79 | $sql = 'delete from ' . $table_name . ' where post_id=' . $postId; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | public function save_post($postId, $postObject, $update, $state = false) |
| 85 | 85 | { |
| 86 | 86 | $postType = false; |
| 87 | - if (! $postObject) { |
|
| 87 | + if ( ! $postObject) { |
|
| 88 | 88 | //postObject not set, check if $_POST has post_type |
| 89 | 89 | if (isset($_POST['post_type'])) { |
| 90 | 90 | $postType = $_POST['post_type']; |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $postType = $postObject->post_type; |
| 95 | 95 | } |
| 96 | 96 | //Neither $postObject nor $_POST[post_type] set return here. |
| 97 | - if (! $postType) { |
|
| 97 | + if ( ! $postType) { |
|
| 98 | 98 | return; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | $columns = array_merge($defaultCols, $customCols); |
| 113 | 113 | do_action('krn_flattable_pre_write_' . $postType, $columns, $postObject); |
| 114 | 114 | //check if there are any other than required columns, we dont need an "empty" table |
| 115 | - if(empty($customCols)) { |
|
| 115 | + if (empty($customCols)) { |
|
| 116 | 116 | return; |
| 117 | 117 | } |
| 118 | 118 | //check if table exists, and if table has atleast required columns |
@@ -129,11 +129,11 @@ discard block |
||
| 129 | 129 | $checkRow = $this->wpdb->get_row("select post_id from $table_name where post_id=" . $postId); |
| 130 | 130 | //if we have already a published record, update it |
| 131 | 131 | $update = true; |
| 132 | - if (! $checkRow) { |
|
| 132 | + if ( ! $checkRow) { |
|
| 133 | 133 | $update = false; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - if (! $update) { |
|
| 136 | + if ( ! $update) { |
|
| 137 | 137 | //INSERT |
| 138 | 138 | $updateCols = ['post_type', 'post_id']; |
| 139 | 139 | $updateVals = ["'" . $postType . "'", $postId]; |