Skip to content

Commit

Permalink
Merge branch 'fix-issue-32'
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximeCulea committed Mar 19, 2019
2 parents e258c3b + 2e6c8b9 commit 19c95de
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions classes/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,27 @@ class Helpers {
* @return string
*/
public static function original_option_id( $post_id ) {
// Check if is an object.
// Todo user case.
if ( is_object( $post_id ) ) {
// Apply for all cases.
switch ( get_class( $post_id ) ) {
case 'WP_Term':
$post_id = $post_id->taxonomy . '_' . $post_id->term_id;
break;
case 'WP_Comment':
$post_id = 'comment_' . $post_id->comment_ID;
break;
case 'WP_Post':
$post_id = $post_id->ID;
break;
}
}

return str_replace( sprintf( '_%s', pll_current_language( 'locale' ) ), '', $post_id );
}


/**
* Check if the given post id is from an options page or not
*
Expand All @@ -33,6 +51,7 @@ public static function is_option_page( $post_id ) {
}

$options_pages = self::get_option_page_ids();

return ! empty( $options_pages ) && in_array( $post_id, $options_pages );
}

Expand Down

0 comments on commit 19c95de

Please sign in to comment.