post_type, $post_id->ID ) ) { // post $post_id = $post_id->ID; } elseif ( isset( $post_id->roles, $post_id->ID ) ) { // user $post_id = 'user_' . $post_id->ID; } elseif ( isset( $post_id->taxonomy, $post_id->term_id ) ) { // term $post_id = acf_get_term_post_id( $post_id->taxonomy, $post_id->term_id ); } elseif ( isset( $post_id->comment_ID ) ) { // comment $post_id = 'comment_' . $post_id->comment_ID; } else { // default $post_id = 0; } } // allow for option == options if ( 'option' === $post_id ) { $post_id = 'options'; } return str_replace( sprintf( '_%s', pll_current_language( 'locale' ) ), '', $post_id ); } /** * Check if the given post id is from an options page or not * * @param string $post_id * * @return bool * @author Maxime CULEA * * @since 1.0.2 */ public static function is_option_page( $post_id ) { $post_id = self::original_option_id( $post_id ); if ( false !== strpos( $post_id, 'option' ) ) { return true; } $options_pages = self::get_option_page_ids(); if ( empty( $options_pages ) ) { return false; } return in_array( $post_id, $options_pages, false ); } /** * Get all registered options pages as array [ menu_slug => post_id ] * * @return array * @author Maxime CULEA * * @since 1.0.2 */ public static function get_option_page_ids() { return wp_list_pluck( acf_options_page()->get_pages(), 'post_id' ); } /** * Define if a post id has already been localized fr_FR * * @param $post_id * * @since 1.1.7 * @author Maxime CULEA * * @return bool */ public static function already_localized( $post_id ) { preg_match( '/[a-z]{2}_[A-Z]{2}/', $post_id, $language ); return ! empty( $language ); } }