phpwordpresswordpress-themingcustom-wordpress-pages

how to list compatible devices for functions php file


First time making a website into a wordpress theme and I am watching a youtube video from 2019 and they put all for compatible devices but when I go to the theme it says "Fatal error: Uncaught Error: Undefined constant "all"". Is there another way or a better tutorial that would have more up to date information.

<?php 

// adding the css and js files

function cm_setup() {
  wp_enqueue_style('google-fonts', '//fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;
  0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
  wp_enqueue_style('fontawesome', '//kit.fontawesome.com/a8cbd25639.js');
  wp_enqueue_style('style', get_stylesheet_uri(), NULL, microtime(), all);
  wp_enqueue_script("main", get_theme_file_uri('/js/main.js'), NULL, microtime(), true);
}

add_action('wp_enqueue_scripts', 'cm_setup');


Solution

  • Media should be string. refer the documentation.

    wp_enqueue_style('style', get_stylesheet_uri(), [], '1.0.0', 'all');
    

    [wp_enqueue_style][1] [1]: https://developer.wordpress.org/reference/functions/wp_enqueue_style/