Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ************************
- **** Comments ****
- ************************
- /*
- Theme Name: Twenty Fifteen Child
- Theme URI: http://example.com/twenty-fifteen-child/
- Description: Twenty Fifteen Child Theme
- Author: John Doe
- Author URI: http://example.com
- Template: twentyfifteen
- Version: 1.0.0
- License: GNU General Public License v2 or later
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
- Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
- Text Domain: twentyfifteenchild
- */
- /*
- Plugin Name: Ijoo Divi Blog Module
- Plugin URI: https://sitefixing.com/ijoo
- Description: Advanced blog/magazine module for Divi
- Version: 1.0.1
- Author: Ijjou Agurram
- License: GPL2
- License URI: https://www.gnu.org/licenses/gpl-2.0.html
- Text Domain: ijoo
- Ijoo is free software:
- */
- /**
- * Template Name: Full Width Page
- *
- * @package WordPress
- * @subpackage Twenty_Fourteen
- * @since Twenty Fourteen 1.0
- */
- ************************
- **** WP tags ****
- ************************
- <body <?php body_class(); ?>>
- <?php wp_footer() ?> // before </body>
- ************************
- **** Custom Fields ****
- ************************
- <p>Today's Mood: <?php echo get_post_meta($post->ID, 'Mood', true); ?></p>
- ************************
- **** Loops ****
- ************************
- $recent_posts = wp_get_recent_posts(array(‘numberposts’=>3));
- foreach($recent_posts as $recent){
- echo '<li><a href="' . get_permalink($recent["ID"]) . '">' . $recent["post_title"] . '</a></li> ';
- }
- ************************
- **** Shortcode ****
- ************************
- function new_shortcode($atts, $content = null) {
- extract(shortcode_atts(array(
- “type” => “warning”
- ), $atts));
- return '<div class="alert alert-'.$type.'">'.$content.'</div>';
- }
- add_shortcode(“warning_box”, “new_shortcode”);
- ************************
- **** Enqueue ****
- ************************
- function wpdocs_theme_name_scripts() {
- wp_enqueue_style( 'style-name', get_stylesheet_uri() );
- wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
- }
- add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_scripts' );
- ==== Plugin
- if (!defined('PLUGIN_PATH')) {
- define('PLUGIN_PATH', plugin_dir_url(__FILE__));
- }
- wp_register_style('my_plugin_stylesheet', PLUGIN_PATH . 'css/styles.css' );
- wp_enqueue_style('my_plugin_stylesheet');
- get_stylesheet_uri() = http://example.com/wp-content/themes/example-child/style.css
- get_template_directory_uri() = http://example.com/wp-content/themes/example-parent
- get_stylesheet_directory_uri() = http://example.com/wp-content/themes/example-child
- **** Dequeue ****
- function PREFIX_remove_scripts() {
- wp_dequeue_style( 'put_modules_file_handler_here' );
- wp_deregister_style( 'put_modules_file_handler_here' );
- // Now register your child CSS here, using wp_enqueue_style
- }
- add_action( 'wp_enqueue_scripts', 'PREFIX_remove_scripts', 20 );
- ************************
- **** Replace text - Schedule ****
- ************************
- function replace_hello($the_content){
- if(current_time('G')<=10){
- $the_content=preg_replace('/\bhello\b/','good morning',$the_content); // \b to make sure hello is word (not targetting Schellong)
- $the_content=preg_replace('/\bHello\b/','Good Morning',$the_content); “word boundary” anchor
- }
- return $the_content;
- }
- add_filter('the_content', 'replace_hello');
- ************************
- **** $wpdb ****
- ************************
- $fivesdrafts = $wpdb->get_results(
- "
- SELECT *
- FROM $wpdb->posts
- WHERE post_status = 'draft'
- AND post_author = 5
- "
- );
- insert( $table, $data, $format );
- $wpdb->insert(
- 'table',
- array(
- 'column1' => 'value1',
- 'column2' => 123,
- ),
- array(
- '%s',
- '%d',
- )
- );
- $table: table name
- $data: array( 'col' => 'val', 'col2' => 'val2')
- $format: %s as string; %d as integer (whole number); and %f as float...
- update( $table, $data, $where, $format = null, $where_format = null );
- $wpdb->update(
- 'table',
- array(
- 'column1' => 'value1', // string
- 'column2' => 'value2' // integer (number)
- ),
- array( 'ID' => 1 ),
- array(
- '%s', // value1
- '%d' // value2
- ),
- array( '%d' )
- );
- ************************
- **** Widget ****
- ************************
- class My_Widget extends WP_Widget {
- /**
- * Sets up the widgets name etc
- */
- public function __construct() {
- $widget_ops = array(
- 'classname' => 'my_widget',
- 'description' => 'My Widget is awesome',
- );
- parent::__construct( 'my_widget', 'My Widget', $widget_ops );
- }
- /**
- * Outputs the content of the widget
- *
- * @param array $args
- * @param array $instance
- */
- public function widget( $args, $instance ) {
- // outputs the content of the widget
- }
- /**
- * Outputs the options form on admin
- *
- * @param array $instance The widget options
- */
- public function form( $instance ) {
- // outputs the options form on admin
- }
- /**
- * Processing widget options on save
- *
- * @param array $new_instance The new options
- * @param array $old_instance The previous options
- *
- * @return array
- */
- public function update( $new_instance, $old_instance ) {
- // processes widget options to be saved
- }
- }
Add Comment
Please, Sign In to add comment