get_all_campaign_ids( $args['post_parent'] ); unset( $args['post_parent'] ); return $args; } /** * Returns the list of all IDs that belong under this campaign's umbrella. * * @param int $campaign_id * @return array * @since alpha-0.1 */ private function get_all_campaign_ids( $campaign_id ) { $parent_campaign = get_post_meta($campaign_id, '_icl_lang_duplicate_of', true); if ( !strlen( $parent_campaign ) ) { $parent_campaign = $campaign_id; } return $this->get_merged_campaign_ids( $parent_campaign ); } /** * Returns the list of IDs of all children campaigns. * * @global $wpdb; * @param int $parent_id * @return array * @since alpha-0.1 */ private function get_merged_campaign_ids( $parent_id ) { global $wpdb; return array_merge( array( $parent_id ), $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_icl_lang_duplicate_of' AND meta_value = %d;", $parent_id ) ) ); } }