faybobo

Untitled

Feb 25th, 2022 (edited)
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.43 KB | None | 0 0
  1.  
  2. ************************
  3. **** Comments ****
  4. ************************
  5. /*
  6. Theme Name: Twenty Fifteen Child
  7. Theme URI: http://example.com/twenty-fifteen-child/
  8. Description: Twenty Fifteen Child Theme
  9. Author: John Doe
  10. Author URI: http://example.com
  11. Template: twentyfifteen
  12. Version: 1.0.0
  13. License: GNU General Public License v2 or later
  14. License URI: http://www.gnu.org/licenses/gpl-2.0.html
  15. Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
  16. Text Domain: twentyfifteenchild
  17. */
  18. /*
  19. Plugin Name: Ijoo Divi Blog Module
  20. Plugin URI: https://sitefixing.com/ijoo
  21. Description: Advanced blog/magazine module for Divi
  22. Version: 1.0.1
  23. Author: Ijjou Agurram
  24. License: GPL2
  25. License URI: https://www.gnu.org/licenses/gpl-2.0.html
  26. Text Domain: ijoo
  27.  
  28. Ijoo is free software:
  29. */
  30. /**
  31. * Template Name: Full Width Page
  32. *
  33. * @package WordPress
  34. * @subpackage Twenty_Fourteen
  35. * @since Twenty Fourteen 1.0
  36. */
  37.  
  38. ************************
  39. **** WP tags ****
  40. ************************
  41. <body <?php body_class(); ?>>
  42. <?php wp_footer() ?> // before </body>
  43.  
  44. ************************
  45. **** Custom Fields ****
  46. ************************
  47. <p>Today's Mood: <?php echo get_post_meta($post->ID, 'Mood', true); ?></p>
  48.  
  49. ************************
  50. **** Loops ****
  51. ************************
  52. $recent_posts = wp_get_recent_posts(array(‘numberposts’=>3));
  53. foreach($recent_posts as $recent){
  54. echo '<li><a href="' . get_permalink($recent["ID"]) . '">' . $recent["post_title"] . '</a></li> ';
  55. }
  56.  
  57. ************************
  58. **** Shortcode ****
  59. ************************
  60. function new_shortcode($atts, $content = null) {
  61. extract(shortcode_atts(array(
  62. “type” => “warning”
  63. ), $atts));
  64. return '<div class="alert alert-'.$type.'">'.$content.'</div>';
  65. }
  66. add_shortcode(“warning_box”, “new_shortcode”);
  67.  
  68. ************************
  69. **** Enqueue ****
  70. ************************
  71. function wpdocs_theme_name_scripts() {
  72. wp_enqueue_style( 'style-name', get_stylesheet_uri() );
  73. wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
  74. }
  75. add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_scripts' );
  76.  
  77. ==== Plugin
  78. if (!defined('PLUGIN_PATH')) {
  79. define('PLUGIN_PATH', plugin_dir_url(__FILE__));
  80. }
  81. wp_register_style('my_plugin_stylesheet', PLUGIN_PATH . 'css/styles.css' );
  82. wp_enqueue_style('my_plugin_stylesheet');
  83.  
  84. get_stylesheet_uri() = http://example.com/wp-content/themes/example-child/style.css
  85. get_template_directory_uri() = http://example.com/wp-content/themes/example-parent
  86. get_stylesheet_directory_uri() = http://example.com/wp-content/themes/example-child
  87.  
  88. **** Dequeue ****
  89. function PREFIX_remove_scripts() {
  90. wp_dequeue_style( 'put_modules_file_handler_here' );
  91. wp_deregister_style( 'put_modules_file_handler_here' );
  92.  
  93. // Now register your child CSS here, using wp_enqueue_style
  94. }
  95. add_action( 'wp_enqueue_scripts', 'PREFIX_remove_scripts', 20 );
  96.  
  97. ************************
  98. **** Replace text - Schedule ****
  99. ************************
  100. function replace_hello($the_content){
  101. if(current_time('G')<=10){
  102. $the_content=preg_replace('/\bhello\b/','good morning',$the_content); // \b to make sure hello is word (not targetting Schellong)
  103. $the_content=preg_replace('/\bHello\b/','Good Morning',$the_content); “word boundary” anchor
  104. }
  105. return $the_content;
  106. }
  107. add_filter('the_content', 'replace_hello');
  108.  
  109. ************************
  110. **** $wpdb ****
  111. ************************
  112. $fivesdrafts = $wpdb->get_results(
  113. "
  114. SELECT *
  115. FROM $wpdb->posts
  116. WHERE post_status = 'draft'
  117. AND post_author = 5
  118. "
  119. );
  120.  
  121. insert( $table, $data, $format );
  122. $wpdb->insert(
  123. 'table',
  124. array(
  125. 'column1' => 'value1',
  126. 'column2' => 123,
  127. ),
  128. array(
  129. '%s',
  130. '%d',
  131. )
  132. );
  133. $table: table name
  134. $data: array( 'col' => 'val', 'col2' => 'val2')
  135. $format: %s as string; %d as integer (whole number); and %f as float...
  136.  
  137.  
  138. update( $table, $data, $where, $format = null, $where_format = null );
  139. $wpdb->update(
  140. 'table',
  141. array(
  142. 'column1' => 'value1', // string
  143. 'column2' => 'value2' // integer (number)
  144. ),
  145. array( 'ID' => 1 ),
  146. array(
  147. '%s', // value1
  148. '%d' // value2
  149. ),
  150. array( '%d' )
  151. );
  152.  
  153. ************************
  154. **** Widget ****
  155. ************************
  156. class My_Widget extends WP_Widget {
  157. /**
  158. * Sets up the widgets name etc
  159. */
  160. public function __construct() {
  161. $widget_ops = array(
  162. 'classname' => 'my_widget',
  163. 'description' => 'My Widget is awesome',
  164. );
  165. parent::__construct( 'my_widget', 'My Widget', $widget_ops );
  166. }
  167.  
  168. /**
  169. * Outputs the content of the widget
  170. *
  171. * @param array $args
  172. * @param array $instance
  173. */
  174. public function widget( $args, $instance ) {
  175. // outputs the content of the widget
  176. }
  177.  
  178. /**
  179. * Outputs the options form on admin
  180. *
  181. * @param array $instance The widget options
  182. */
  183. public function form( $instance ) {
  184. // outputs the options form on admin
  185. }
  186.  
  187. /**
  188. * Processing widget options on save
  189. *
  190. * @param array $new_instance The new options
  191. * @param array $old_instance The previous options
  192. *
  193. * @return array
  194. */
  195. public function update( $new_instance, $old_instance ) {
  196. // processes widget options to be saved
  197. }
  198. }
Add Comment
Please, Sign In to add comment