Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825
Warning: foreach() argument must be of type array|object, string given in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 830
Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825
Automator_Review::get_recipes_using_credits()
Callback for getting recipes using api credits.
Contents
Warning: foreach() argument must be of type array|object, string given in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 830
Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825
Parameters Parameters
- $request
(Required)
Return Return
(object)
Source Source
File: src/core/admin/class-automator-review.php
public function get_recipes_using_credits() { global $wpdb; $integration_codes = array( 'GOOGLESHEET', 'SLACK', 'MAILCHIMP', 'TWITTER', 'FACEBOOK', 'INSTAGRAM' ); $where_meta = []; foreach ( $integration_codes as $code ) { $where_meta[] = " `meta_value` LIKE '{$code}' "; } $meta = implode( ' OR ', $where_meta ); $check_recipes = $wpdb->get_col( "SELECT rp.ID as ID FROM {$wpdb->posts} cp LEFT JOIN {$wpdb->posts} rp ON rp.ID = cp.post_parent WHERE cp.ID IN (SELECT post_id FROM {$wpdb->postmeta} WHERE {$meta} ) AND cp.post_status LIKE 'publish' AND rp.post_status LIKE 'publish' " ); // The rest response object $response = (object) []; $response->success = true; $recipes = []; if ( ! empty( $check_recipes ) ) { foreach ( $check_recipes as $recipe_id ) { // Get the title $recipe_title = get_the_title( $recipe_id ); $recipe_title = ! empty( $recipe_title ) ? $recipe_title : sprintf( __( 'ID: %s (no title)', 'uncanny-automator' ), $recipe_id ); // Get the URL $recipe_edit_url = get_edit_post_link( $recipe_id ); // Get the recipe type $recipe_type = Automator()->utilities->get_recipe_type( $recipe_id ); // Get the times per user $recipe_times_per_user = ''; if ( $recipe_type == 'user' ) { $recipe_times_per_user = get_post_meta( $recipe_id, 'recipe_completions_allowed', true ); } // Get the total allowed completions $recipe_allowed_completions_total = get_post_meta( $recipe_id, 'recipe_max_completions_allowed', true ); // Get the number of runs $recipe_number_of_runs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(run_number) FROM {$wpdb->prefix}uap_recipe_log WHERE automator_recipe_id=%d AND completed = %d", $recipe_id, 1 ) ); $recipes[] = [ 'id' => $recipe_id, 'title' => $recipe_title, 'url' => $recipe_edit_url, 'type' => $recipe_type, 'times_per_user' => $recipe_times_per_user, 'allowed_completions_total' => $recipe_allowed_completions_total, 'completed_runs' => $recipe_number_of_runs, ]; } } $response->recipes = $recipes; $response = new \WP_REST_Response( $response, 200 ); return $response; }
Expand full source code Collapse full source code View on Github
Changelog Changelog
Version | Description |
---|---|
3.1 | Introduced. |