difference of each codes for wordpress

I'm studying wordpress development and i was bumped to this codes. i'm trying my best to look from google but i can't seem to find it. Just wondering if what these codes means.

  1. what does the /admin stands for in the theme_css_uri?

    define( 'name_THEME_URI',                       get_stylesheet_directory_uri());
    define( 'name_THEME_TEMPLATE_URI',              name_THEME_URI . '/templates' );
    define( 'name_THEME_LANGUAGES_URI',             name_THEME_URI . '/languages' );
    define( 'name_THEME_ASSETS_URI',                name_THEME_URI     . '/assets' );
    define( 'name_THEME_JS_URI',                    name_THEME_ASSETS_URI . '/js' );
    define( 'name_THEME_CSS_URI',                   name_THEME_ASSETS_URI . '/css' );
    define( 'name_THEME_IMAGES_URI',                name_THEME_ASSETS_URI . '/images' );
    define( 'name_THEME_ADMIN_JS_URI',              name_THEME_JS_URI . '/admin' );
    define( 'name_THEME_ADMIN_CSS_URI',             name_THEME_CSS_URI . '/admin' );
    

2.what does the two dollar sign means and why does the code changed from get_stylesheet_directory_uri(); to $name_template_directory_uri

 $name_template_directory_uri = get_stylesheet_directory_uri();

 function name_register_js() {

global $name_template_directory_uri;
wp_register_script('nectar_priority', $name_template_directory_uri . '/js/priority.js', 'jquery', '',TRUE);

} 
add_action('wp_enqueue_scripts', 'name_register_js');

Hope someone can help me. thank you

Topic constants Wordpress

Category Web


  1. First, check how define works on PHP. It defines a named constant, /admin is just a folder, in this case, it's a folder that you have creatied to save JS files that are admin-related, that folder is located on name_THEME_ASSETS_URI which you previously defined as well as: name_THEME_ASSETS_URI . '/js', so /admin is a folder inside /js which is inside of /templates which is inside of your theme directory.

  2. The dollar sign means, it's a variable, I recommend you to read a couple of basic PHP tutorials to give you a better understanding of those basic concepts.

While get_stylesheet_directory_uri() is a function, so please, read about variables and functions on PHP. It's a good start.

In general, it's highly recommended that you learn PHP, since WordPress is written in PHP and you will get lost fast if you don't know PHP, so I'd suggest you take a few days to learn that language and then come back to WordPress and you will understand everything more easily.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.