Excellent Programming Tricks

Wordpress Theme Development | Fundament Basics | Enqueue | Style | Scripts


  1. When you want to install WordPress, you can change the database prefix (wp_). Because every hacker knows the prefix table name of the database table.
  2. The essential starting files for a WordPress theme are index.php, style.css, screenshot.png(1200px{w}X900px{h}) and functions.php.
  3. For visual studio code
    1. User WordPress Snippets (wpprotools.io) extensions. 
    2. VS Code marks every function as Undefined function 
      1. Click Settings and search for “stubs” then click on “intelephense” extension and then scroll down to bottom. Click add new item and then add wordpress. [Ref:https://wordpress.org/support ]
  4. <html lang="<?php language_attributes();?>" class="no-js">
    1. no-js - The previous jQuery file is not allowed.
  5. <meta charset="<?php bloginfo('charset');?>">
  6. Add wp_head() and wp_footer();
  7. The sticky post has the height priority. 
  8. singular.php for the post page. Page.php for the page. Can be
    1. index.php -->
      1. Folder Template
        1. blog_setup.php
          1. singular.php 
    2. page.php -->
      1. Folder Template
        1. page_setup.php
          1. page.php
  9. Add body_class(); [<body class="<?php body_class(); ?>"]
  10. Theme Test Data Master
    1. https://github.com/WordPress/theme-test-data
      1. themeunittestdata.wordpress.xml
    2. https://codex.wordpress.org/Theme_Unit_Test
  11. Enqueue Function
    1. function function_name() {}
    2. First register [except styel.css]
      1. wp_register_style('custom', get_template_directory_uri().'/assets/css/custom.css', array ('bootstrap'), '5.3.3','all');
      2. wp_enqueue_style('custom');
    3. add_action('wp_enqueue_scripts', 'function_name'); -- For Theme Development
    4. add_action('admin_enqueue_scripts' , 'function_name') -- For Plugin Development
    5. OOP [For specific situation]
      1. function enqueue_action(){
        add_action( 'admin_enqueue_scripts', array($this, 'enqueue_scripts' ))
        } -- enqueue_action and enqueue_scripts are function name. Call classname->enqueue_action
  12. Enqueue Style
    1. wp_enqueue_style( $handle, $src, $deps, $ver, $media ); 
    2. wp_enqueue_style( 'myStyle', get_template_directory_uri() . '/css/myCssStyle.css', array('mizan'), '3.3.6', 'all'  ); --For Theme Development
    3. wp_enqueue_style( 'mypluginstyle', plugins_url('/assets/mystyle.css', __FILE__) ); -- For Plugin Development
    4. You have to enqueue style.css.
      1. wp_enqueue_style('base_style', get_stylesheet_uri());
      2. Register not required.
  13. Enqueue Script
    1. If you only need to enqueue a script without needing to register it for future use.
    2. To include jQuery in your project (manually adding isn't required)
      1. wp_enqueue_script('jquery'); 
    3. wp_enqueue_script( $handle, $src, $deps = array(), string|bool|null $var = false, $in_footer = false)
    4. wp_enqueue_script( 'abc_js', get_template_directory_uri() . '/js/myjs.js', array('jquery'), '3.3.6', true );
    5. wp_enqueue_script( 'myScript' , plugins_url( '/assets/myscript.js', __FILE__ ) );
  14. wp_enqueue_style('dashicons');
  15. Remove Style
    1. wp_deregister_style( $handle )
  16. Remove Script
    1. wp_deregister_script( $handle )
  17. Image
    1. <img src="<?php echo get_template_directory_uri(); ?>/assets/img/logo.png" alt="">

No comments:

Post a Comment


Authentic аnd Excellent

Website

HTML Template

Wordpress Theme

Database applications

OR

Application services?

Excellent Programming Tricks (EPT) || Iftekhar-IT || We develops the Web applications and the WordPress templates. || Excellent Programming Tricks (EPT)

© 2020 Blogger Theme by Iftekhar IT || Excellent Programming Tricks

Execllent Programming Tricks. Powered by Blogger.