WordPress主题额外CSS的实现

在数据表wp_options中看到

optinon_id:  114       

option_name: theme_mods_twentytwenty     

option_value:
a:20:{s:18:"custom_css_post_id";i:163;s:16:"sidebars_widgets";a:2:{s:4:"time";i:1576923935;s:4:"data";a:3:{s:19:"wp_inactive_widgets";a:0:{}s:9:"sidebar-1";a:1:{i:0;s:6:"text-4";}s:9:"sidebar-2";a:1:{i:0;s:6:"text-5";}}}s:18:"nav_menu_locations";a:1:{s:7:"primary";i:2;}s:16:"background_color";s:6:"58168e";s:17:"accent_hue_active";s:7:"default";s:10:"accent_hue";i:344;s:24:"accent_accessible_colors";a:2:{s:7:"content";a:5:{s:4:"text";s:7:"#ffffff";s:6:"accent";s:7:"#e88ba4";s:10:"background";s:7:"#58168e";s:7:"borders";s:7:"#7619c2";s:9:"secondary";s:7:"#c8b2db";}s:13:"header-footer";a:5:{s:4:"text";s:7:"#000000";s:6:"accent";s:7:"#9c1035";s:10:"background";s:7:"#81d742";s:7:"borders";s:7:"#64b629";s:9:"secondary";s:7:"#2d4020";}}s:30:"header_footer_background_color";s:7:"#81d742";s:20:"enable_header_search";b:1;s:15:"show_author_bio";b:1;s:12:"blog_content";s:4:"full";s:39:"cover_template_overlay_background_color";s:7:"#1e73be";s:33:"cover_template_overlay_text_color";s:7:"#dd3333";s:30:"cover_template_overlay_opacity";i:0;s:11:"custom_logo";i:157;s:16:"background_image";s:48:"http://wp.com/wp-content/uploads/2020/01/bg2.jpg";s:17:"background_preset";s:3:"fit";s:15:"background_size";s:7:"contain";s:17:"background_repeat";s:9:"no-repeat";s:21:"background_attachment";s:5:"fixed";}     

 
option_value是序列化后的值,

用函数查询 option_name: theme_mods_twentytwenty的值

 ";
      var_dump(get_option('theme_mods_twentytwenty')); 
?>
array(20) {
  ["custom_css_post_id"]=>
  int(163)
  ["sidebars_widgets"]=>
  array(2) {
    ["time"]=>
    int(1576923935)
    ["data"]=>
    array(3) {
      ["wp_inactive_widgets"]=>
      array(0) {
      }
      ["sidebar-1"]=>
      array(1) {
        [0]=>
        string(6) "text-4"
      }
      ["sidebar-2"]=>
      array(1) {
        [0]=>
        string(6) "text-5"
      }
    }
  }
  ["nav_menu_locations"]=>
  array(1) {
    ["primary"]=>
    int(2)
  }
  ["background_color"]=>
  string(6) "ffd699"
  ["accent_hue_active"]=>
  string(7) "default"
  ["accent_hue"]=>
  int(344)
  ["accent_accessible_colors"]=>
  array(2) {
    ["content"]=>
    array(5) {
      ["text"]=>
      string(7) "#000000"
      ["accent"]=>
      string(7) "#c2093a"
      ["background"]=>
      string(7) "#ffd699"
      ["borders"]=>
      string(7) "#fdad34"
      ["secondary"]=>
      string(7) "#5f461f"
    }
    ["header-footer"]=>
    array(5) {
      ["text"]=>
      string(7) "#000000"
      ["accent"]=>
      string(7) "#9c1035"
      ["background"]=>
      string(7) "#81d742"
      ["borders"]=>
      string(7) "#64b629"
      ["secondary"]=>
      string(7) "#2d4020"
    }
  }
  ["header_footer_background_color"]=>
  string(7) "#81d742"
  ["enable_header_search"]=>
  bool(true)
  ["show_author_bio"]=>
  bool(true)
  ["blog_content"]=>
  string(4) "full"
  ["cover_template_overlay_background_color"]=>
  string(7) "#1e73be"
  ["cover_template_overlay_text_color"]=>
  string(7) "#dd3333"
  ["cover_template_overlay_opacity"]=>
  int(0)
  ["custom_logo"]=>
  int(157)
  ["background_image"]=>
  string(48) "http://wp.com/wp-content/uploads/2020/01/bg2.jpg"
  ["background_preset"]=>
  string(3) "fit"
  ["background_size"]=>
  string(7) "contain"
  ["background_repeat"]=>
  string(9) "no-repeat"
  ["background_attachment"]=>
  string(5) "fixed"
}
	
["custom_css_post_id"]=>int(163)

 在wp_post 中看到 id=163

id:163
post_content:body{color:red;}
post_title:twentytwenty
post_type:custom_css

WordPress主题额外CSS的实现_第1张图片

可见它把css设置存在了wp_post中

你可能感兴趣的:(wordpress)