PHP code example of bernskioldmedia / wp-plugin-scaffold

1. Go to this page and download the library: Download bernskioldmedia/wp-plugin-scaffold library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bernskioldmedia / wp-plugin-scaffold example snippets


use BernskioldMedia\WP\Block_Plugin_Support\Block;

class My_Thing_Block extends Block {

	/**
	 * Render the content
	 *
	 * @param  array  $attributes
	 *
	 * @return false|string
	 */
	 public static function render( $attributes ): string {

	 	ob_start();
	 	

/**
 * Modify the query.
 *
 * @param  \WP_Query  $query
 *
 * @return \WP_Query
 */
public static function query_modifications( \WP_Query $query ) {

	if ( is_admin() && ! $query->is_main_query() ) {
		return $query;
	}

	if ( $query->get( 'post_type' ) !== static::get_key() ) {
		return $query;
	}

	// $query->set( 'prop', 'value' );

	return $query;

}