AnsPress_Hooks::save_question_hooks( integer $post_id, object $post, boolean $updated )
Description #
Trigger posts hooks right after saving question.
Parameters #
- $post_idinteger (Required) Post ID.
- $postobject (Required) Post Object
- $updatedboolean (Required) Is updating post
Changelog #
Source #
File: includes/hooks.php
public static function save_question_hooks( $post_id, $post, $updated ) { if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) { return; } if ( $updated ) { // Deleted unused images from meta. ap_delete_images_not_in_content( $post_id ); } $form = anspress()->get_form( 'question' ); $values = $form->get_values(); $qameta = array( 'last_updated' => current_time( 'mysql' ), 'answers' => ap_count_published_answers( $post_id ), ); // Check if anonymous post and have name. if ( $form->is_submitted() && ! is_user_logged_in() && ap_allow_anonymous() && ! empty( $values['anonymous_name']['value'] ) ) { $qameta['fields'] = array( 'anonymous_name' => $values['anonymous_name']['value'], ); } /** * Modify qameta args which will be inserted after inserting * or updating question. * * @param array $qameta Qameta arguments. * @param object $post Post object. * @param boolean $updated Is updated. * @since 4.1.0 */ $qameta = apply_filters( 'ap_insert_question_qameta', $qameta, $post, $updated ); ap_insert_qameta( $post_id, $qameta ); if ( $updated ) { /** * Action triggered right after updating question. * * @param integer $post_id Inserted post ID. * @param object $post Inserted post object. * @since 0.9 * @since 4.1.0 Removed `$post->post_type` variable. */ do_action( 'ap_processed_update_question' , $post_id, $post ); } else { /** * Action triggered right after inserting new question. * * @param integer $post_id Inserted post ID. * @param object $post Inserted post object. * @since 0.9 * @since 4.1.0 Removed `$post->post_type` variable. */ do_action( 'ap_processed_new_question', $post_id, $post ); } // Update qameta terms. ap_update_qameta_terms( $post_id ); }
Expand full source code Collapse full source code View on GitHub: includes/hooks.php:658
Add your comment