Add post meta box for custom layouts.

@see   $this->load_post()
@since 1.0.0
@uses  $this->render_meta_box()

@param string  $post_type
@param WP_Post $post
493589
public function add_meta_box( $post_type, WP_Post $post ) {

		if (
			! post_type_supports( $post_type, 'rock-layouts' )
			||
			! current_user_can( 'edit_post_meta', $post->ID )
			||
			! current_user_can( 'add_post_meta', $post->ID )
			||
			! current_user_can( 'delete_post_meta', $post->ID )
		) {

			return;

		}

		add_meta_box(
			'rock-layouts-meta-box',
			esc_html__( 'Layout', 'rock' ),
			array( $this, 'render_meta_box' ),
			$post_type,
			'side',
			'default'
		);

	}
818794
protected function loadPostTypes()
    {
        if ($config = $this->loadConfigFile('post_types.php')) {
            $callbacks = array();

            // Create one callback for each post type, and register in
            // init action

            foreach ($config as $postTypeName => $args) {
                $callbacks[] = $cb = function () use ($postTypeName, $args) {
                    register_post_type($postTypeName, $args);
                };

                add_action('init', $cb, 0);
            }

            // Flush URL caches for (you need to register custom post types
            // first)

            register_activation_hook($this->getPluginFile(), function () use ($callbacks) {
                foreach ($callbacks as $cb) {
                    $cb();
                }

                flush_rewrite_rules();
            });
        }

        return $this;
    }
936675
public function add($_type = null)
    {
        if (empty($this->Settings['formFields'])) {
            $columns = $this->Model->schema()->columns();
            $filter = Configure::read('PostTypes.FilteredColumns');
            foreach ($columns as $column) {
                if (!in_array($column, $filter)) {
                    $this->Settings['formFields'][$column] = [];
                }
            }
        }

        // setting up an event for the add
        $_event = new Event('Controller.PostTypes.beforeAdd.' . $this->_type, $this, [
        ]);
        $this->eventManager()->dispatch($_event);

        $type = $this->Model->newEntity();
        if ($this->request->is('post')) {
            $type = $this->Model->newEntity($this->request->data);
            if ($this->Model->save($type)) {
                $this->Flash->success(__('The {0} has been saved.', [$this->Settings['type']]));
                return $this->redirect(['action' => 'index', 'type' => $this->_type]);
            } else {
                $this->Flash->error(__('The {0} could not be saved. Please, try again.', [$this->Settings['type']]));
            }
        }
        $this->set(compact('type'));

        // setting up an event for the add
        $_event = new Event('Controller.PostTypes.afterAdd.' . $this->_type, $this, [
        ]);
        $this->eventManager()->dispatch($_event);

        if (!$this->Settings['views']['add']) {
            $this->render(Configure::read('PostTypes.AdminPostTypeViews.add'));
            return;
        }

        $this->render($this->Settings['views']['add']);
    }
448390
public function addPost(Post $post)
    {
        $postName = $post->getName();

        if ($this->isPostRegistered($postName)) {
            throw new \InvalidArgumentException("Duplicate post $postName");
        }

        $this->registerPost($post);
    }
1182529
public function registered_post_type( string $post_type, WP_Post_Type $post_type_object ) {
		if ( $post_type !== $this->post_type ) {
			return;
		}
		$struct = str_replace( "%{$this->post_type}_slug%", $this->post_slug, $post_type_object->rewrite['permastruct'] );
		$struct = str_replace( '%postname%', "%{$this->post_type}%", $struct );
		add_permastruct( $this->post_type, $struct, $post_type_object->rewrite );
	}
1281786
private function createPostTypes()
    {
        if(!$this->option('posts') && ($this->option('post_types') || $this->option('all'))) {
            $this->comment('Creating dummy Post Types...');
            $output = (new \PostTypeSeeder())
                ->setCommand($this)
                ->run($this->getDefaultOption('post_types'));
            $this->info($output);
        }
        return $this;
    }
239433
private function add_relationships($post_type)
    {
        if (! empty($this->taxonomies)) {
            $filters = [];

            foreach ($this->taxonomies as $k => $v) {
                // Add all taxonomies to $filters unless explicitly declared otherwise.
                if (\is_integer($k)) {
                    $post_type->taxonomy($v);
                    $filters[] = $v;
                    continue;
                }

                if ($v === false) {
                    $post_type->taxonomy($k);
                }
            }

            $post_type->filters($filters);
        }
    }
381763
public function add_image_sizes_meta_to_media($form_meta, $post = null)
    {
        if (wp_attachment_is_image($post->ID) && current_user_can('manage_options')) {
            $meta = wp_get_attachment_metadata($post->ID);

            $form_meta .= '<strong>Available sizes: </strong>' . \count($meta['sizes']);
        }

        return $form_meta;
    }
356109
public static function displayItems ($post_type = 'any', array $args = array(), $callback = null, array $params = array())
    {
        $query = new \WP_Query(array_merge(array(
            'post_type' => $post_type
        ), $args));
        if ($query->have_posts()) {
            global $post;
            while ($query->have_posts()) {
                $query->the_post();
                if ($callback !== null)
                    call_user_func_array($callback, array_merge(array($post), $params));
            }
            wp_reset_postdata();
        }
        return $query;
    }
1100644
public function render($postId)
    {
        $meta = $this->metabox->getMeta($postId);

        $this->getField()->getManager()->renderPreview(
            Arr::get($meta, $this->path)
        );
    }
127772
public function render_metaboxes_custom( $post, $args ) {

		// include the metabox view
		echo '<input type="hidden" name="pods_templates_metabox" id="pods_templates_metabox" value="' . esc_attr( wp_create_nonce( plugin_basename( __FILE__ ) ) ) . '" />';
		echo '<input type="hidden" name="pods_templates_metabox_prefix[]" value="' . esc_attr( $args['args']['slug'] ) . '" />';

		// get post meta to $atts $ post content - ir the widget option
		if ( ! empty( $post ) ) {
			$atts    = get_post_meta( $post->ID, $args['args']['slug'], true );
			$content = $post->post_content;
		} else {
			$atts    = get_option( $args['args']['slug'] );
			$content = '';
		}

		if ( file_exists( $this->get_path( __FILE__ ) . 'includes/element-' . $args['args']['slug'] . '.php' ) ) {
			include $this->get_path( __FILE__ ) . 'includes/element-' . $args['args']['slug'] . '.php';
		} elseif ( file_exists( $this->get_path( __FILE__ ) . 'includes/element-' . $args['args']['slug'] . '.html' ) ) {
			include $this->get_path( __FILE__ ) . 'includes/element-' . $args['args']['slug'] . '.html';
		}
		// add script
		if ( file_exists( $this->get_path( __FILE__ ) . 'assets/js/scripts-' . $args['args']['slug'] . '.php' ) ) {
			echo "<script type=\"text/javascript\">\r\n";
			include $this->get_path( __FILE__ ) . 'assets/js/scripts-' . $args['args']['slug'] . '.php';
			echo "</script>\r\n";
		} elseif ( file_exists( $this->get_path( __FILE__ ) . 'assets/js/scripts-' . $args['args']['slug'] . '.js' ) ) {
			wp_enqueue_script( $this->plugin_slug . '-' . $args['args']['slug'] . '-script', $this->get_url( 'assets/js/scripts-' . $args['args']['slug'] . '.js', __FILE__ ), array( 'jquery' ), self::VERSION, true );
		}

	}
1023186
public function metaBoxPostTypes()
    {
	global $modularityOptions;
	$enabled = isset($modularityOptions['enabled-post-types']) && is_array($modularityOptions['enabled-post-types']) ? $modularityOptions['enabled-post-types'] : array();

	$postTypes = array_filter(get_post_types(), function ($item) {
	    $disallowed = array_merge(
		array_keys(\Modularity\ModuleManager::$available),
		array(
		    'attachment',
		    'revision',
		    'nav_menu_item',
		    'custom_css',
		    'customize_changeset'
		)
	    );

	    if (in_array($item, $disallowed)) {
		return false;
	    }

	    if (substr($item, 0, 4) == 'acf-') {
		return false;
	    }

	    return true;
	});

	include MODULARITY_TEMPLATE_PATH . 'options/partials/modularity-post-types.php';
    }
574801
public function _wp_seo_meta_box( $post ) {
		?>
		<?php wp_nonce_field( 'wp-seo-meta-box-action', 'wp-seo-meta-box-nonce' ); ?>
		<p>
			<label for="wp-seo-meta-description">
				<b><?php esc_html_e( 'Meta description', 'inc2734-wp-seo' ); ?></b>
			</label><br />
			<input
				type="text"
				name="wp-seo-meta-description"
				class="widefat"
				id="wp-seo-meta-description"
				value="<?php echo esc_attr( get_post_meta( $post->ID, 'wp-seo-meta-description', true ) ); ?>"
			/>
		</p>
		<p>
			<b><?php esc_html_e( 'Meta robots', 'inc2734-wp-seo' ); ?></b><br />
			<?php
			$robots = (array) get_post_meta( $post->ID, 'wp-seo-meta-robots', true );
			$robots_choices = [
				'noindex',
				'nofollow',
			]
			?>
			<?php foreach ( $robots_choices as $robot ) : ?>
				<label for="wp-seo-meta-robots-<?php echo esc_attr( $robot ); ?>" style="margin-right: 1em;">
					<input
						type="checkbox"
						name="wp-seo-meta-robots[]"
						id="wp-seo-meta-robots-<?php echo esc_attr( $robot ); ?>"
						value="<?php echo esc_attr( $robot ); ?>"
						<?php checked( in_array( $robot, $robots ) ); ?>
					/>
					<?php echo esc_html( $robot ); ?>
				</label>
			<?php endforeach; ?>
		</p>
		<?php
	}
1207080
public function render( $post ) 
    {
        $old_instance = \get_post_meta( $post->ID, $this->settings['id'], true );
        $this->form->updater->update( $old_instance === "" ? array() : $old_instance );
        // Add an nonce field so we can check for it later.
        wp_nonce_field( $this->action_name(), $this->nonce_name() );
        $this->form->render(true);
    }
198723
public function save_post( $post_id ) {

		if (
			empty( $_POST['rock-layout-nonce'] )
			||
			! wp_verify_nonce( $_POST['rock-layout-nonce'], basename( __FILE__ ) )
		) {

			return;

		}

		$override = ! empty( $_POST['rock-layout-override'] );
		$current  = $this->get_post_layout( $post_id );

		if ( ! $override && $current ) {

			delete_post_meta( $post_id, 'rock_layout' );

			return;

		}

		$layout = isset( $_POST['rock-layout'] ) ? sanitize_key( $_POST['rock-layout'] ) : null;

		if ( ! $override || ! $this->layout_exists( $layout ) || $layout === $current ) {

			return;

		}

		update_post_meta( $post_id, 'rock_layout', $layout );

	}
968226
public function add_meta_boxes( $post_type )
    {    
        if ( in_array( $post_type, $this->settings['post_types'] )) {
            add_meta_box(
                $this->settings['id'],
                $this->settings['title'],
                array( $this, 'render' ),
                $post_type,
                $this->settings['context'],
                $this->settings['priority']
            );
        }
    }
1223379
public function render( \WP_Post $post ){
        $this->nonce_field();
        $this->desc();
        echo '<table class="table form-table wpametu-meta-table">';
        foreach( $this->loop_fields() as $field ){
            if( !is_wp_error($field) ){
                /** @var \WPametu\UI\Field\Base $field */
                $field->render($post);
            }else{
                /** @var \WP_Error $field */
                printf('<div class="error"><p>%s</p></div>', $field->get_error_message());
            }
        }
        echo '</table>';
    }