Suspend
1 week ago
ActionScheduler.php
1 week ago
AdminPages.php
1 week ago
AdminUrl.php
1 week ago
DB.php
1 week ago
Post.php
1 week ago
Resources.php
1 week ago
SyncHash.php
1 week ago
WCTaxonomies.php
1 week ago
WcAdminPages.php
1 week ago
WpAdminPages.php
1 week ago
Post.php
30 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WCML\Utilities; |
| 4 | |
| 5 | use WPML\FP\Fns; |
| 6 | |
| 7 | class Post { |
| 8 | |
| 9 | public static function insert( array $args, $lang = null, $trid = null ) { |
| 10 | $saveInLang = $saveWithTrid = null; |
| 11 | |
| 12 | if ( $lang ) { |
| 13 | $saveInLang = Fns::always( $lang ); |
| 14 | add_filter( 'wpml_save_post_lang', $saveInLang ); |
| 15 | } |
| 16 | |
| 17 | if ( $trid ) { |
| 18 | $saveWithTrid = Fns::always( $trid ); |
| 19 | add_filter( 'wpml_save_post_trid_value', $saveWithTrid ); |
| 20 | } |
| 21 | |
| 22 | $newPostId = wp_insert_post( $args ); |
| 23 | |
| 24 | remove_filter( 'wpml_save_post_lang', $saveInLang ); |
| 25 | remove_filter( 'wpml_save_post_trid_value', $saveWithTrid ); |
| 26 | |
| 27 | return $newPostId; |
| 28 | } |
| 29 | } |
| 30 |