PluginProbe
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI / 6.0.3
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI v6.0.3
6.0.3 6.0.2 6.0.1 6.0.0 5.8.6 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 5.7.9.2 5.7.9.1 5.7.8 5.7.9 5.7.6 5.7.7 5.7.5 5.7.4 5.7.3 5.7.2 5.7.1 trunk 5.6.0 5.6.1 All 34 releases
← All changes | libraries/ct/includes/functions.php +100 -13 5.8.6 → 6.0.3 View file →
@@ -118,48 +118,103 @@
118 118 */
119 119 function ct_get_table_labels( $ct_table ) {
120 120
121 121 $default_labels = array(
122 + // translators: %1$s: Singular
122 123 'name' => '%1$s',
124 + // translators: %1$s: Singular
123 125 'singular_name' => '%1$s',
126 + // translators: %2$s: Plural
124 127 'plural_name' => '%2$s',
125 128 'add_new' => __('Add New', 'ct'),
129 + // translators: %1$s: Singular
126 130 'add_new_item' => __('Add New %1$s', 'ct'),
131 + // translators: %1$s: Singular
127 132 'edit_item' => __('Edit %1$s', 'ct'),
133 + // translators: %1$s: Singular
128 134 'new_item' => __('New %1$s', 'ct'),
135 + // translators: %1$s: Singular
129 136 'view_item' => __('View %1$s', 'ct'),
137 + // translators: %2$s: Plural
130 138 'view_items' => __('View %2$s', 'ct'),
139 + // translators: %2$s: Plural
131 140 'search_items' => __( 'Search %2$s', 'ct' ),
141 + // translators: %2$s: Plural
132 142 'not_found' => __( 'No %2$s found.', 'ct' ),
143 + // translators: %2$s: Plural
133 144 'not_found_in_trash' => __( 'No %2$s found in Trash.', 'ct' ),
145 + // translators: %1$s: Singular
134 146 'parent_item_colon' => __( 'Parent %1$s:', 'ct' ),
147 + // translators: %2$s: Plural
135 148 'all_items' => __( 'All %2$s', 'ct' ),
149 + // translators: %1$s: Singular
136 150 'archives' => __( '%1$s Archives', 'ct' ),
151 + // translators: %1$s: Singular
137 152 'attributes' => __( '%1$s Attributes', 'ct' ),
153 + // translators: %1$s: Singular
138 154 'insert_into_item' => __( 'Insert into %1$s', 'ct' ),
155 + // translators: %1$s: Singular
139 156 'uploaded_to_this_item' => __( 'Uploaded to this %1$s', 'ct' ),
140 157 'featured_image' => __( 'Featured Image', 'ct' ),
141 158 'set_featured_image' => __( 'Set featured image', 'ct' ),
142 159 'remove_featured_image' => __( 'Remove featured image', 'ct' ),
143 160 'use_featured_image' => __( 'Use as featured image', 'ct' ),
161 + // translators: %2$s: Plural
144 162 'filter_items_list' => __( 'Filter %2$s list', 'ct' ),
163 + // translators: %2$s: Plural
145 164 'items_list_navigation' => __( '%2$s list navigation', 'ct' ),
165 + // translators: %2$s: Plural
146 166 'items_list' => __( '%2$s list', 'ct' ),
147 - // Views
167 +
168 + // -- VIEWS --
169 +
170 + // translators: %2$s: Plural
148 171 'list_page_title' => '%2$s',
172 + // translators: %2$s: Plural
149 173 'list_menu_title' => __( 'All %2$s', 'ct' ),
150 174 'add_page_title' => __('Add New', 'ct'),
151 175 'add_menu_title' => __('Add New', 'ct'),
176 + // translators: %1$s: Singular
152 177 'edit_page_title' => __('Edit %1$s', 'ct'),
178 + // translators: %1$s: Singular
153 179 'edit_menu_title' => __('Edit %1$s', 'ct'),
154 - // Messages
180 +
181 + // -- MESSAGES --
182 +
183 + // translators: %2$s: Plural
155 184 'add_item_not_allowed' => __( 'Sorry, you are not allowed to add new %2$s.', 'ct' ),
185 + // translators: %1$s: Singular
156 186 'edit_item_not_allowed' => __( 'Sorry, you are not allowed to edit this %1$s.', 'ct' ),
187 + // translators: %2$s: Plural
157 188 'edit_items_not_allowed' => __( 'Sorry, you are not allowed to edit %2$s.', 'ct' ),
189 + // translators: %1$s: Singular
158 190 'edit_item_deleted' => __( 'You attempted to edit a %1$s that doesn’t exist. Perhaps it was deleted?', 'ct' ),
191 + // translators: %1$s: Singular
159 192 'delete_item_not_allowed' => __( 'Sorry, you are not allowed to delete this %1$s.', 'ct' ),
193 + // translators: %2$s: Plural
160 194 'delete_items_not_allowed' => __( 'Sorry, you are not allowed to delete %2$s.', 'ct' ),
195 + // translators: %s: Singular
161 196 'delete_item_confirm' => __( "Are you sure you want to delete this %s?\\n\\nClick \\'Cancel\\' to go back, \\'OK\\' to confirm the delete.", 'ct' ),
197 +
198 + // -- TEXTS --
199 +
200 + // translators: %s: Singular %d: ID
201 + 'select_item' => __( 'Select %s #%d', 'ct' ),
202 + // translators: %s: Singular %d: ID
203 + 'item_locked' => __( '“%s #%d” is locked', 'ct' ),
204 +
205 + // -- ERROR --
206 +
207 + // translators: %1$s: Singular
208 + 'insert_error' => __( 'Could not insert %1$s into the database', 'ct' ),
209 + // translators: %s: Singular
210 + 'update_error' => __( '%s could not be updated.', 'ct' ),
211 + // translators: %s: Singular
212 + 'update_success' => __( '%s updated successfully.', 'ct' ),
213 + // translators: %1$s: Singular
214 + 'delete_error' => __( 'The %1$s cannot be deleted.', 'ct' ),
215 +
216 +
162 217 );
163 218
164 219 // Use this hook to override default labels in your plugin with the plugin text domain
165 220 $default_labels = apply_filters( 'ct_default_table_labels', $default_labels );
@@ -518,9 +573,9 @@
518 573 $object = ct_get_object( $object_data[$primary_key], ARRAY_A );
519 574
520 575 if ( is_null( $object ) ) {
521 576 if ( $wp_error )
522 - return new WP_Error( 'invalid_object', __( 'Invalid object ID.' ) );
577 + return new WP_Error( 'invalid_object', __( 'Invalid item ID.' ) );
523 578 return 0;
524 579 }
525 580
526 581 // Escape data pulled from DB.
@@ -583,9 +638,9 @@
583 638
584 639 if ( is_null( $original_object_data ) ) {
585 640
586 641 if ( $wp_error ) {
587 - return new WP_Error( 'invalid_object', __( 'Invalid object ID.', 'ct' ) );
642 + return new WP_Error( 'invalid_object', __( 'Invalid item ID.' ) );
588 643 }
589 644
590 645 return 0;
591 646 }
@@ -614,13 +669,15 @@
614 669 *
615 670 * @param int $object_id Object ID.
616 671 * @param array $data Array of unslashed object data.
617 672 */
673 + do_action( 'ct_pre_object_update', $object_id, $object_data );
674 + // Backward Compatibility
618 675 do_action( 'pre_object_update', $object_id, $object_data );
619 676
620 677 if ( false === $ct_table->db->update( $object_data, $where ) ) {
621 678 if ( $wp_error ) {
622 - return new WP_Error('db_update_error', __('Could not update object in the database'), $wpdb->last_error);
679 + return new WP_Error('db_update_error', __( 'Could not update object in the database', 'ct' ), $wpdb->last_error);
623 680 } else {
624 681 return 0;
625 682 }
626 683 }
@@ -639,9 +696,9 @@
639 696
640 697 if ( false === $wpdb->insert( $ct_table->db->table_name, $object_data ) ) {
641 698
642 699 if ( $wp_error ) {
643 - return new WP_Error('db_insert_error', __('Could not insert object into the database'), $wpdb->last_error);
700 + return new WP_Error('db_insert_error', ct_get_table_label( $ct_table->name, 'insert_error' ), $wpdb->last_error);
644 701 } else {
645 702 return 0;
646 703 }
647 704
@@ -749,9 +806,9 @@
749 806
750 807 global $wpdb, $ct_table;
751 808
752 809 if( ! is_a( $ct_table, 'CT_Table' ) ) {
753 - return new WP_Error( 'invalid_ct_table', __( 'Invalid CT Table object.' ) );
810 + return new WP_Error( 'invalid_ct_table', __( 'Invalid CT Table object.', 'ct' ) );
754 811 }
755 812
756 813 $ct_object = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$ct_table->db->table_name} WHERE {$ct_table->db->primary_key} = %d", $object_id ) );
757 814
@@ -774,9 +831,11 @@
774 831 * @param bool $delete Whether to go forward with deletion.
775 832 * @param WP_Post $post Post object.
776 833 * @param bool $force_delete Whether to bypass the trash.
777 834 */
778 - $check = apply_filters( 'pre_delete_object', null, $ct_object, $force_delete );
835 + $check = apply_filters( 'ct_pre_delete_object', null, $ct_object, $force_delete );
836 + // Backward Compatibility
837 + $check = apply_filters( 'pre_delete_object', $check, $ct_object, $force_delete );
779 838 if ( null !== $check ) {
780 839 return $check;
781 840 }
782 841
@@ -788,8 +847,9 @@
788 847 * @see ct_delete_object()
789 848 *
790 849 * @param int $object_id Object ID.
791 850 */
851 + do_action( 'ct_before_delete_object', $object_id );
792 852 do_action( 'before_delete_object', $object_id );
793 853
794 854 if( $ct_table->meta ) {
795 855 ct_delete_object_meta( $object_id, '_wp_trash_meta_status' );
@@ -808,8 +868,9 @@
808 868 * @since 1.0.0
809 869 *
810 870 * @param int $object_id Object ID.
811 871 */
872 + do_action( 'ct_delete_object', $object_id );
812 873 do_action( 'delete_object', $object_id );
813 874
814 875 $result = $ct_table->db->delete( $object_id );
815 876
@@ -823,8 +884,9 @@
823 884 * @since 1.0.0
824 885 *
825 886 * @param int $object_id Object ID.
826 887 */
888 + do_action( 'ct_deleted_object', $object_id );
827 889 do_action( 'deleted_object', $object_id );
828 890
829 891 ct_clean_object_cache( $ct_object );
830 892
@@ -836,8 +898,9 @@
836 898 * @see ct_delete_object()
837 899 *
838 900 * @param int $object_id Object ID.
839 901 */
902 + do_action( 'ct_after_delete_object', $object_id );
840 903 do_action( 'after_delete_object', $object_id );
841 904
842 905 return $ct_object;
843 906 }
@@ -897,9 +960,11 @@
897 960 * @param mixed $meta_value Meta value. Must be serializable if non-scalar.
898 961 * @param bool $unique Whether the specified meta key should be unique
899 962 * for the object. Optional. Default false.
900 963 */
901 - $check = apply_filters( "add_{$ct_table->name}_metadata", null, $object_id, $meta_key, $meta_value, $unique );
964 + $check = apply_filters( "ct_add_{$ct_table->name}_metadata", null, $object_id, $meta_key, $meta_value, $unique );
965 + // Backward compatibility
966 + $check = apply_filters( "add_{$ct_table->name}_metadata", $check, $object_id, $meta_key, $meta_value, $unique );
902 967 if ( null !== $check )
903 968 return $check;
904 969
905 970 if ( $unique && $wpdb->get_var( $wpdb->prepare(
@@ -921,8 +986,10 @@
921 986 * @param int $object_id Object ID.
922 987 * @param string $meta_key Meta key.
923 988 * @param mixed $meta_value Meta value.
924 989 */
990 + do_action( "ct_add_{$ct_table->name}_meta", $object_id, $meta_key, $_meta_value );
991 + // Backward compatibility
925 992 do_action( "add_{$ct_table->name}_meta", $object_id, $meta_key, $_meta_value );
926 993
927 994 $result = $wpdb->insert( $meta_table_name, array(
928 995 $primary_key => $object_id,
@@ -949,8 +1016,10 @@
949 1016 * @param int $object_id Object ID.
950 1017 * @param string $meta_key Meta key.
951 1018 * @param mixed $meta_value Meta value.
952 1019 */
1020 + do_action( "ct_added_{$ct_table->name}_meta", $mid, $object_id, $meta_key, $_meta_value );
1021 + // Backward compatibility
953 1022 do_action( "added_{$ct_table->name}_meta", $mid, $object_id, $meta_key, $_meta_value );
954 1023
955 1024 return $mid;
956 1025 }
@@ -1009,9 +1078,11 @@
1009 1078 * @param bool $delete_all Whether to delete the matching metadata entries
1010 1079 * for all objects, ignoring the specified $object_id.
1011 1080 * Default false.
1012 1081 */
1013 - $check = apply_filters( "delete_{$ct_table->name}_metadata", null, $object_id, $meta_key, $meta_value, $delete_all );
1082 + $check = apply_filters( "ct_delete_{$ct_table->name}_metadata", null, $object_id, $meta_key, $meta_value, $delete_all );
1083 + // Backward compatibility
1084 + $check = apply_filters( "delete_{$ct_table->name}_metadata", $check, $object_id, $meta_key, $meta_value, $delete_all );
1014 1085 if ( null !== $check )
1015 1086 return (bool) $check;
1016 1087
1017 1088 $_meta_value = $meta_value;
@@ -1050,8 +1121,10 @@
1050 1121 * @param int $object_id Object ID.
1051 1122 * @param string $meta_key Meta key.
1052 1123 * @param mixed $meta_value Meta value.
1053 1124 */
1125 + do_action( "ct_delete_{$ct_table->name}_meta", $meta_ids, $object_id, $meta_key, $_meta_value );
1126 + // Backward compatibility
1054 1127 do_action( "delete_{$ct_table->name}_meta", $meta_ids, $object_id, $meta_key, $_meta_value );
1055 1128
1056 1129 $query = "DELETE FROM $meta_table_name WHERE $meta_primary_key IN( " . implode( ',', $meta_ids ) . " )";
1057 1130
@@ -1080,8 +1153,10 @@
1080 1153 * @param int $object_id Object ID.
1081 1154 * @param string $meta_key Meta key.
1082 1155 * @param mixed $meta_value Meta value.
1083 1156 */
1157 + do_action( "ct_deleted_{$ct_table->name}_meta", $meta_ids, $object_id, $meta_key, $_meta_value );
1158 + // Backward compatibility
1084 1159 do_action( "deleted_{$ct_table->name}_meta", $meta_ids, $object_id, $meta_key, $_meta_value );
1085 1160
1086 1161 return true;
1087 1162 }
@@ -1126,9 +1201,11 @@
1126 1201 * @param int $object_id Object ID.
1127 1202 * @param string $meta_key Meta key.
1128 1203 * @param bool $single Whether to return only the first value of the specified $meta_key.
1129 1204 */
1130 - $check = apply_filters( "get_{$ct_table->name}_metadata", null, $object_id, $meta_key, $single );
1205 + $check = apply_filters( "ct_get_{$ct_table->name}_metadata", null, $object_id, $meta_key, $single );
1206 + // Backward compatibility
1207 + $check = apply_filters( "get_{$ct_table->name}_metadata", $check, $object_id, $meta_key, $single );
1131 1208 if ( null !== $check ) {
1132 1209 if ( $single && is_array( $check ) )
1133 1210 return $check[0];
1134 1211 else
@@ -1223,9 +1300,11 @@
1223 1300 * @param mixed $prev_value Optional. If specified, only update existing
1224 1301 * metadata entries with the specified value.
1225 1302 * Otherwise, update all entries.
1226 1303 */
1227 - $check = apply_filters( "update_{$ct_table->name}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value );
1304 + $check = apply_filters( "ct_update_{$ct_table->name}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value );
1305 + // backward compatibility
1306 + $check = apply_filters( "update_{$ct_table->name}_metadata", $check, $object_id, $meta_key, $meta_value, $prev_value );
1228 1307 if ( null !== $check )
1229 1308 return (bool) $check;
1230 1309
1231 1310 // Compare existing value to new value if no prev value given and the key exists only once.
@@ -1269,8 +1348,10 @@
1269 1348 * @param int $object_id Object ID.
1270 1349 * @param string $meta_key Meta key.
1271 1350 * @param mixed $meta_value Meta value.
1272 1351 */
1352 + do_action( "ct_update_{$ct_table->name}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
1353 + // Backward compatibility
1273 1354 do_action( "update_{$ct_table->name}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
1274 1355 }
1275 1356
1276 1357 $result = $ct_table->meta->db->update( $data, $where );
@@ -1293,8 +1374,10 @@
1293 1374 * @param int $object_id Object ID.
1294 1375 * @param string $meta_key Meta key.
1295 1376 * @param mixed $meta_value Meta value.
1296 1377 */
1378 + do_action( "ct_updated_{$ct_table->name}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
1379 + // Backward compatibility
1297 1380 do_action( "updated_{$ct_table->name}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
1298 1381 }
1299 1382
1300 1383 return true;
@@ -1466,8 +1549,10 @@
1466 1549 if ( $meta = ct_get_metadata_by_mid( $meta_type, $meta_id ) ) {
1467 1550 $object_id = $meta->{$meta_primary_key};
1468 1551
1469 1552 /** This action is documented in wp-includes/meta.php */
1553 + do_action( "ct_delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value );
1554 + // Backward compatibility
1470 1555 do_action( "delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value );
1471 1556
1472 1557 // Run the query, will return true if deleted, false otherwise
1473 1558 $result = (bool) $wpdb->delete( $meta_table_name, array( $meta_primary_key => $meta_id ) );
@@ -1475,8 +1560,10 @@
1475 1560 // Clear the caches.
1476 1561 wp_cache_delete($object_id, $meta_type . '_meta');
1477 1562
1478 1563 /** This action is documented in wp-includes/meta.php */
1564 + do_action( "ct_deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value );
1565 + // Backward compatibility
1479 1566 do_action( "deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value );
1480 1567
1481 1568 return $result;
1482 1569
@@ -1569,9 +1656,9 @@
1569 1656 <p><strong><?php esc_html_e( 'Add New Custom Field:' ) ?></strong></p>
1570 1657 <table id="newmeta">
1571 1658 <thead>
1572 1659 <tr>
1573 - <th class="left"><label for="<?php echo $meta_key_input_id; ?>"><?php _ex( 'Name', 'meta name' ) ?></label></th>
1660 + <th class="left"><label for="<?php echo esc_attr( $meta_key_input_id ); ?>"><?php echo esc_html( _x( 'Name', 'meta name' ) ); ?></label></th>
1574 1661 <th><label for="metavalue"><?php esc_html_e( 'Value' ) ?></label></th>
1575 1662 </tr>
1576 1663 </thead>
1577 1664