" . __( 'Failed to load the unit.', 'amazon-auto-links' ) . ""; } // At this point, it is an ajax request (admin-ajax.php + `{wp_ajax_/wp_ajax_nopriv_}aal_unit_ajax_loading` action hook ) // For the contextual widget add_filter( 'aal_filter_http_get', array( $this, 'replyToSetReferrerHTTPGET' ) ); add_filter( 'aal_filter_post_object', array( $this, 'replyToSetReferrerPostObject' ) ); add_filter( 'aal_filter_current_page_type', array( $this, 'replyToSetReferrerPageType' ) ); add_filter( 'aal_filter_current_queried_term_object', array( $this, 'replyToSetReferrerTermObject' ) ); add_filter( 'aal_filter_current_queried_author', array( $this, 'replyToSetReferrerAuthor' ) ); $_aData = $_POST[ 'data' ]; // For widget outputs, retrieve the widget instance options. if ( isset( $_aData[ '_widget_option_name' ] ) ) { $_aWidgetOptions = get_option( $_aData[ '_widget_option_name' ] ); $_aData = $this->getElement( $_aWidgetOptions, $_aData[ '_widget_number' ] ); } echo $this->___getOutput( $_aData ); die(); // this is required to return a proper result } /** * @param array $aArguments * @since 3.6.0 * @return string */ private function ___getOutput( $aArguments ) { // `load_with_javascript` must be set to false as it just returns the Ajax replacement output. $aArguments[ 'load_with_javascript' ] = false; return AmazonAutoLinks( $aArguments, false ); } /** * @param $aGET * @return array * @since 3.6.0 */ public function replyToSetReferrerHTTPGET( $aGET ) { return isset( $_POST[ 'REQUEST' ] ) ? $_POST[ 'REQUEST' ] : $aGET; } /** * @since 3.6.0 * @return object The referrer's post object. */ public function replyToSetReferrerPostObject( $oPost ) { return isset( $_POST[ 'post_id' ] ) && $_POST[ 'post_id' ] ? get_post( $_POST[ 'post_id' ] ) : $oPost; } /** * @return string * @since 3.6.0 */ public function replyToSetReferrerPageType( $sPageType ) { return isset( $_POST[ 'page_type' ] ) && $_POST[ 'page_type' ] ? $_POST[ 'page_type' ] : $sPageType; } /** * @return object * @since 3.6.0 */ public function replyToSetReferrerTermObject( $oTerm ) { return isset( $_POST[ 'term_id' ] ) && $_POST[ 'term_id' ] ? get_term( $_POST[ 'term_id' ] ) : $oTerm; } /** * @return string * @since 3.6.0 */ public function replyToSetReferrerAuthor( $sAuthor ) { return isset( $_POST[ 'author_name' ] ) && $_POST[ 'author_name' ] ? $_POST[ 'author_name' ] : $sAuthor; } }