Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function cmsmasters_options_reinit_run() {
- $atts = array(
- array(
- 'cmsmasters_post_type' => 'page',
- 'cmsmasters_meta' => array(
- 'cmsmasters_heading_height' => "323"
- )
- )
- );
- cmsmasters_options_reinit($atts);
- }
- add_action('init', 'cmsmasters_options_reinit_run');
- function cmsmasters_options_reinit($atts) {
- foreach ($atts as $attr) {
- $query = new WP_Query(array(
- 'post_type' => $attr['cmsmasters_post_type'],
- 'posts_per_page' => -1
- ));
- if ($query->have_posts()) {
- while ($query->have_posts()) {
- $query->the_post();
- foreach ($attr['cmsmasters_meta'] as $meta_key => $new_meta) {
- $old_meta = get_post_meta(get_the_ID(), $meta_key, true);
- if (isset($new_meta) && $new_meta !== $old_meta) {
- update_post_meta(get_the_ID(), $meta_key, $new_meta);
- }
- }
- }
- }
- wp_reset_postdata();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement