A fork of the WordPress Twenty Seventeen theme; used to power the Sandia Mesa websites.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1286 lines
39 KiB

  1. <?php
  2. /**
  3. * Simple Nineteen functions and definitions
  4. *
  5. * @link https://developer.wordpress.org/themes/basics/theme-functions/
  6. *
  7. * @package Simple_Nineteen
  8. * @since 1.0
  9. */
  10. /**
  11. * Twenty Seventeen only works in WordPress 4.7 or later.
  12. */
  13. if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '<' ) ) {
  14. require get_template_directory() . '/inc/back-compat.php';
  15. return;
  16. }
  17. /**
  18. * Sets up theme defaults and registers support for various WordPress features.
  19. *
  20. * Note that this function is hooked into the after_setup_theme hook, which
  21. * runs before the init hook. The init hook is too late for some features, such
  22. * as indicating support for post thumbnails.
  23. */
  24. function simplenineteen_setup() {
  25. /*
  26. * Make theme available for translation.
  27. * Translations can be filed at WordPress.org. See: https://translate.wordpress.org/projects/wp-themes/twentyseventeen
  28. * If you're building a theme based on Twenty Seventeen, use a find and replace
  29. * to change 'simplenineteen' to the name of your theme in all the template files.
  30. */
  31. load_theme_textdomain( 'simplenineteen' );
  32. // Add default posts and comments RSS feed links to head.
  33. add_theme_support( 'automatic-feed-links' );
  34. /*
  35. * Let WordPress manage the document title.
  36. * By adding theme support, we declare that this theme does not use a
  37. * hard-coded <title> tag in the document head, and expect WordPress to
  38. * provide it for us.
  39. */
  40. add_theme_support( 'title-tag' );
  41. /*
  42. * Enable support for Post Thumbnails on posts and pages.
  43. *
  44. * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
  45. */
  46. add_theme_support( 'post-thumbnails' );
  47. add_image_size( 'simplenineteen-featured-image', 2000, 1200, true );
  48. add_image_size( 'simplenineteen-thumbnail-avatar', 100, 100, true );
  49. // Set the default content width.
  50. $GLOBALS['content_width'] = 525;
  51. // This theme uses wp_nav_menu() in two locations.
  52. register_nav_menus(
  53. array(
  54. 'top' => __( 'Top Menu', 'simplenineteen' ),
  55. )
  56. );
  57. /*
  58. * Switch default core markup for search form, comment form, and comments
  59. * to output valid HTML5.
  60. */
  61. add_theme_support(
  62. 'html5',
  63. array(
  64. 'comment-form',
  65. 'comment-list',
  66. 'gallery',
  67. 'caption',
  68. )
  69. );
  70. /*
  71. * Enable support for Post Formats.
  72. *
  73. * See: https://codex.wordpress.org/Post_Formats
  74. */
  75. add_theme_support(
  76. 'post-formats',
  77. array(
  78. 'aside',
  79. 'image',
  80. 'video',
  81. 'quote',
  82. 'link',
  83. 'gallery',
  84. 'audio',
  85. )
  86. );
  87. // Add theme support for Custom Logo.
  88. add_theme_support(
  89. 'custom-logo',
  90. array(
  91. 'width' => 250,
  92. 'height' => 250,
  93. 'flex-width' => true,
  94. )
  95. );
  96. // Add theme support for selective refresh for widgets.
  97. add_theme_support( 'customize-selective-refresh-widgets' );
  98. // Load regular editor styles into the new block-based editor.
  99. add_theme_support( 'editor-styles' );
  100. // Load default block styles.
  101. add_theme_support( 'wp-block-styles' );
  102. // Add support for responsive embeds.
  103. add_theme_support( 'responsive-embeds' );
  104. // Define and register starter content to showcase the theme on new sites.
  105. $starter_content = array(
  106. 'widgets' => array(
  107. // Place three core-defined widgets in the sidebar area.
  108. 'sidebar-1' => array(
  109. 'text_business_info',
  110. 'search',
  111. 'text_about',
  112. ),
  113. // Add the core-defined business info widget to the footer 1 area.
  114. 'sidebar-2' => array(
  115. 'text_business_info',
  116. ),
  117. // Put two core-defined widgets in the footer 2 area.
  118. 'sidebar-3' => array(
  119. 'text_about',
  120. 'search',
  121. ),
  122. 'site-info' => array(
  123. 'text_site_info' => array( 'text', array(
  124. 'text' => join( '', array(
  125. _x( '<p class="sample">Here would be a good spot to put links to your Privacy Policy and Terms of Service.</p>', 'Theme starter content', 'simplenineteen'),
  126. _x( '<p class="imprint">This website was made using the Simple Nineteen theme.</p>', 'Theme starter content', 'simplenineteen'),
  127. ) ),
  128. ) ),
  129. 'meta',
  130. ),
  131. ),
  132. // Specify the core-defined pages to create and add custom thumbnails to some of them.
  133. 'posts' => array(
  134. 'home',
  135. 'about' => array(
  136. 'thumbnail' => '{{image-sandwich}}',
  137. ),
  138. 'contact' => array(
  139. 'thumbnail' => '{{image-espresso}}',
  140. ),
  141. 'blog' => array(
  142. 'thumbnail' => '{{image-coffee}}',
  143. ),
  144. 'homepage-section' => array(
  145. 'thumbnail' => '{{image-espresso}}',
  146. ),
  147. ),
  148. // Create the custom image attachments used as post thumbnails for pages.
  149. 'attachments' => array(
  150. 'image-espresso' => array(
  151. 'post_title' => _x( 'Espresso', 'Theme starter content', 'simplenineteen' ),
  152. 'file' => 'assets/images/espresso.jpg', // URL relative to the template directory.
  153. ),
  154. 'image-sandwich' => array(
  155. 'post_title' => _x( 'Sandwich', 'Theme starter content', 'simplenineteen' ),
  156. 'file' => 'assets/images/sandwich.jpg',
  157. ),
  158. 'image-coffee' => array(
  159. 'post_title' => _x( 'Coffee', 'Theme starter content', 'simplenineteen' ),
  160. 'file' => 'assets/images/coffee.jpg',
  161. ),
  162. ),
  163. // Default to a static front page and assign the front and posts pages.
  164. 'options' => array(
  165. 'show_on_front' => 'page',
  166. 'page_on_front' => '{{home}}',
  167. 'page_for_posts' => '{{blog}}',
  168. ),
  169. // Set up nav menus for each of the two areas registered in the theme.
  170. 'nav_menus' => array(
  171. // Assign a menu to the "top" location.
  172. 'top' => array(
  173. 'name' => __( 'Top Menu', 'simplenineteen' ),
  174. 'items' => array(
  175. 'link_home', // Note that the core "home" page is actually a link in case a static front page is not used.
  176. 'page_about',
  177. 'page_blog',
  178. 'page_contact',
  179. ),
  180. ),
  181. ),
  182. );
  183. /**
  184. * Filters Twenty Seventeen array of starter content.
  185. *
  186. * @since Twenty Seventeen 1.1
  187. *
  188. * @param array $starter_content Array of starter content.
  189. */
  190. $starter_content = apply_filters( 'simplenineteen_starter_content', $starter_content );
  191. add_theme_support( 'starter-content', $starter_content );
  192. }
  193. add_action( 'after_setup_theme', 'simplenineteen_setup' );
  194. /**
  195. * Adds Simple Nineteen theme updater.
  196. *
  197. * @since Simple Nineteen 1.0.1
  198. *
  199. */
  200. /**
  201. * Updater class.
  202. *
  203. * The theme-review process on w.org takes months.
  204. * In the meantime this can serve as a simple updater.
  205. */
  206. class Updater {
  207. /**
  208. * The repository.
  209. *
  210. * @access private
  211. * @since 1.0.1
  212. * @var string
  213. */
  214. private $repo;
  215. /**
  216. * Theme name.
  217. *
  218. * @access private
  219. * @since 1.0.1
  220. * @var string
  221. */
  222. private $name;
  223. /**
  224. * Theme slug.
  225. *
  226. * @access private
  227. * @since 1.0.1
  228. * @var string
  229. */
  230. private $slug;
  231. /**
  232. * Theme URL.
  233. *
  234. * @access private
  235. * @since 1.0.1
  236. * @var string
  237. */
  238. private $url;
  239. /**
  240. * The response from the API.
  241. *
  242. * @access private
  243. * @since 1.0.1
  244. * @var array
  245. */
  246. private $response;
  247. /**
  248. * Constructor.
  249. *
  250. * @access public
  251. * @since 1.0.1
  252. * @param array $args The arguments for this theme.
  253. */
  254. public function __construct( $args ) {
  255. $this->name = $args['name'];
  256. $this->slug = $args['slug'];
  257. $this->repo = $args['repo'];
  258. $this->ver = $args['ver'];
  259. $this->url = $args['url'];
  260. $this->response = $this->get_response();
  261. // Check for theme updates.
  262. add_filter( 'http_request_args', [ $this, 'update_check' ], 5, 2 );
  263. // Inject theme updates into the response array.
  264. add_filter( 'pre_set_site_transient_update_themes', [ $this, 'update_themes' ] );
  265. add_filter( 'pre_set_transient_update_themes', [ $this, 'update_themes' ] );
  266. }
  267. /**
  268. * Gets the releases URL.
  269. *
  270. * @access private
  271. * @since 1.0.1
  272. * @return string
  273. */
  274. private function get_releases_url() {
  275. return 'https://code.sandiamesa.com/api/v1/repos/' . $this->repo . '/releases';
  276. }
  277. /**
  278. * Get the response from the Gitea API.
  279. *
  280. * @access private
  281. * @since 1.0.1
  282. * @return array
  283. */
  284. private function get_response() {
  285. // If ClassicPress or WordPress is installing, skip
  286. if ( wp_installing() ) {
  287. return;
  288. }
  289. // Remove existing transient
  290. $cache = get_site_transient( md5( $this->get_releases_url() ) );
  291. if ( $cache ) {
  292. delete_site_transient( md5( $this->get_releases_url() ) );
  293. }
  294. $response = wp_remote_get( $this->get_releases_url() );
  295. if ( ! is_wp_error( $response ) && 200 === wp_remote_retrieve_response_code( $response ) ) {
  296. $response = json_decode( wp_remote_retrieve_body( $response ), true );
  297. set_site_transient( md5( $this->get_releases_url() ), $response, 12 * HOUR_IN_SECONDS );
  298. }
  299. // Return new transient
  300. return get_site_transient( md5( $this->get_releases_url() ) );
  301. }
  302. /**
  303. * Get the new version file.
  304. *
  305. * @access private
  306. * @since 1.0.1
  307. * @return string
  308. */
  309. private function get_latest_package() {
  310. if ( ! $this->response ) {
  311. return;
  312. }
  313. foreach ( $this->response as $release ) {
  314. if ( isset( $release['assets'] ) && isset( $release['assets'][0] ) && isset( $release['assets'][0]['browser_download_url'] ) ) {
  315. return $release['assets'][0]['browser_download_url'];
  316. }
  317. }
  318. }
  319. /**
  320. * Get the new version.
  321. *
  322. * @access private
  323. * @since 1.0.1
  324. * @return string
  325. */
  326. private function get_latest_version() {
  327. if ( ! $this->response ) {
  328. return;
  329. }
  330. foreach ( $this->response as $release ) {
  331. if ( isset( $release['tag_name'] ) ) {
  332. return str_replace( 'v', '', $release['tag_name'] );
  333. }
  334. }
  335. }
  336. /**
  337. * Disables requests to the wp.org repository for this theme.
  338. *
  339. * @since 1.0.1
  340. *
  341. * @param array $request An array of HTTP request arguments.
  342. * @param string $url The request URL.
  343. * @return array
  344. */
  345. public function update_check( $request, $url ) {
  346. if ( false !== strpos( $url, '//api.wordpress.org/themes/update-check/1.1/' ) ) {
  347. $data = json_decode( $request['body']['themes'] );
  348. unset( $data->themes->{$this->slug} );
  349. $request['body']['themes'] = wp_json_encode( $data );
  350. }
  351. return $request;
  352. }
  353. /**
  354. * Inject update data for this theme.
  355. *
  356. * @since 1.0.1
  357. *
  358. * @param object $transient The pre-saved value of the `update_themes` site transient.
  359. * @return object
  360. */
  361. public function update_themes( $transient ) {
  362. if ( isset( $transient->checked ) ) {
  363. $current_version = $this->ver;
  364. if ( version_compare( $current_version, $this->get_latest_version(), '<' ) ) {
  365. $transient->response[ $this->name ] = [
  366. 'theme' => $this->name,
  367. 'new_version' => $this->get_latest_version(),
  368. 'url' => 'https://code.sandiamesa.com/' . $this->repo . '/releases',
  369. 'package' => $this->get_latest_package(),
  370. ];
  371. }
  372. }
  373. return $transient;
  374. }
  375. }
  376. new Updater(
  377. [
  378. 'name' => 'Simple Nineteen',
  379. // Theme Name.
  380. 'repo' => 'sandiamesa/simplenineteen',
  381. // Theme repository.
  382. 'slug' => 'simplenineteen',
  383. // Theme Slug.
  384. 'url' => 'https://code.sandiamesa.com/sandiamesa/simplenineteen',
  385. // Theme URL.
  386. 'ver' => '1.2.1'
  387. // Theme Version.
  388. ]
  389. );
  390. /**
  391. * Add the site info section from Twenty Seventeen as a widget.
  392. *
  393. * @since 1.3
  394. */
  395. class Site_Info_widget extends WP_Widget {
  396. /**
  397. * Register widget with WordPress/ClassicPress.
  398. */
  399. public function __construct() {
  400. parent::__construct(
  401. 'simplenineteen_site_info_widget', // Base ID
  402. 'Legacy Site Info Widget', // Name
  403. array( 'description' => __( 'Legacy site info section from Twenty Seventeen as a widget.', 'simplenineteen' ), ) // Args
  404. );
  405. }
  406. /**
  407. * Front-end display of widget.
  408. *
  409. * @see WP_Widget::widget()
  410. *
  411. * @param array $args Widget arguments.
  412. * @param array $instance Saved values from database.
  413. */
  414. public function widget( $args, $instance ) {
  415. extract( $args );
  416. $title = apply_filters( 'widget_title', $instance['title'] );
  417. echo $before_widget;
  418. if ( ! empty( $title ) ) {
  419. echo $before_title . $title . $after_title;
  420. }
  421. if ( function_exists( 'the_privacy_policy_link' ) ) {
  422. the_privacy_policy_link( '', '<span role="separator" aria-hidden="true"></span>' );
  423. }
  424. if ( simplenineteen_is_classicpress() ) { ?>
  425. <a href="<?php echo esc_url( __( 'https://classicpress.net/', 'simplenineteen' ) ); ?>" class="imprint">
  426. <?php /* translators: %s: ClassicPress */ printf( __( 'Proudly powered by %s', 'simplenineteen' ), 'ClassicPress' ); ?>
  427. </a>
  428. <?php } else { ?>
  429. <a href="<?php echo esc_url( __( 'https://wordpress.org/', 'simplenineteen' ) ); ?>" class="imprint">
  430. <?php /* translators: %s: WordPress */ printf( __( 'Proudly powered by %s', 'simplenineteen' ), 'WordPress' ); ?>
  431. </a>
  432. <?php }
  433. echo $after_widget;
  434. }
  435. public function form( $instance ) {
  436. if ( isset( $instance[ 'title' ] ) ) {
  437. $title = $instance[ 'title' ];
  438. }
  439. ?>
  440. <p>
  441. <label for="<?php echo $this->get_field_name( 'title' ); ?>"><?php echo esc_html__( 'Title:', 'simplenineteen' ); ?></label>
  442. <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
  443. </p>
  444. <?php
  445. }
  446. /**
  447. * Sanitize widget form values as they are saved.
  448. *
  449. * @see WP_Widget::update()
  450. *
  451. * @param array $new_instance Values just sent to be saved.
  452. * @param array $old_instance Previously saved values from database.
  453. *
  454. * @return array Updated safe values to be saved.
  455. */
  456. public function update( $new_instance, $old_instance ) {
  457. $instance = array();
  458. $instance['title'] = ( !empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
  459. return $instance;
  460. }
  461. }
  462. // Register Site_Info_Widget
  463. add_action( 'widgets_init', 'register_site_info' );
  464. function register_site_info() {
  465. register_widget( 'Site_Info_Widget' );
  466. }
  467. /**
  468. * Set the content width in pixels, based on the theme's design and stylesheet.
  469. *
  470. * Priority 0 to make it available to lower priority callbacks.
  471. *
  472. * @global int $content_width
  473. */
  474. function simplenineteen_content_width() {
  475. $content_width = $GLOBALS['content_width'];
  476. // Get layout.
  477. $page_layout = get_theme_mod( 'page_layout' );
  478. // Check if layout is one column.
  479. if ( 'one-column' === $page_layout ) {
  480. if ( simplenineteen_is_frontpage() ) {
  481. $content_width = 644;
  482. } elseif ( is_page() ) {
  483. $content_width = 740;
  484. }
  485. }
  486. // Check if is single post and there is no sidebar.
  487. if ( is_single() && ! is_active_sidebar( 'sidebar-1' ) ) {
  488. $content_width = 740;
  489. }
  490. /**
  491. * Filter Twenty Seventeen content width of the theme.
  492. *
  493. * @since Twenty Seventeen 1.0
  494. *
  495. * @param int $content_width Content width in pixels.
  496. */
  497. $GLOBALS['content_width'] = apply_filters( 'simplenineteen_content_width', $content_width );
  498. }
  499. add_action( 'template_redirect', 'simplenineteen_content_width', 0 );
  500. /**
  501. * Register widget area.
  502. *
  503. * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
  504. */
  505. function simplenineteen_widgets_init() {
  506. register_sidebar(
  507. array(
  508. 'name' => __( 'Blog Sidebar', 'simplenineteen' ),
  509. 'id' => 'sidebar-1',
  510. 'description' => __( 'Add widgets here to appear in your sidebar on blog posts and archive pages.', 'simplenineteen' ),
  511. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  512. 'after_widget' => '</section>',
  513. 'before_title' => '<h2 class="widget-title">',
  514. 'after_title' => '</h2>',
  515. )
  516. );
  517. register_sidebar(
  518. array(
  519. 'name' => __( 'Footer 1', 'simplenineteen' ),
  520. 'id' => 'sidebar-2',
  521. 'description' => __( 'Add widgets here to appear in your footer.', 'simplenineteen' ),
  522. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  523. 'after_widget' => '</section>',
  524. 'before_title' => '<h2 class="widget-title">',
  525. 'after_title' => '</h2>',
  526. )
  527. );
  528. register_sidebar(
  529. array(
  530. 'name' => __( 'Footer 2', 'simplenineteen' ),
  531. 'id' => 'sidebar-3',
  532. 'description' => __( 'Add widgets here to appear in your footer.', 'simplenineteen' ),
  533. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  534. 'after_widget' => '</section>',
  535. 'before_title' => '<h2 class="widget-title">',
  536. 'after_title' => '</h2>',
  537. )
  538. );
  539. register_sidebar(
  540. array(
  541. 'name' => __( 'Site Info', 'simplenineteen' ),
  542. 'id' => 'site-info',
  543. 'description' => __( 'Add widgets here to appear in the Site Info section of your footer. Ideas for this section include a link to your Privacy Policy, a link to your Terms of Service, and a Copyright Notice.', 'simplenineteen' ),
  544. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  545. 'after_widget' => '</section>',
  546. 'before_title' => '<h2 class="widget-title">',
  547. 'after_title' => '</h2>',
  548. )
  549. );
  550. }
  551. add_action( 'widgets_init', 'simplenineteen_widgets_init' );
  552. /**
  553. * Replaces "[...]" (appended to automatically generated excerpts) with ... and
  554. * a 'Continue reading' link.
  555. *
  556. * @since Twenty Seventeen 1.0
  557. *
  558. * @param string $link Link to single post/page.
  559. * @return string 'Continue reading' link prepended with an ellipsis.
  560. */
  561. function simplenineteen_excerpt_more( $link ) {
  562. if ( is_admin() ) {
  563. return $link;
  564. }
  565. $link = sprintf(
  566. '<p class="link-more"><a href="%1$s" class="more-link">%2$s</a></p>',
  567. esc_url( get_permalink( get_the_ID() ) ),
  568. /* translators: %s: Name of current post */
  569. sprintf( __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'simplenineteen' ), get_the_title( get_the_ID() ) )
  570. );
  571. return ' &hellip; ' . $link;
  572. }
  573. add_filter( 'excerpt_more', 'simplenineteen_excerpt_more' );
  574. /**
  575. * Handles JavaScript detection.
  576. *
  577. * Adds a `js` class to the root `<html>` element when JavaScript is detected.
  578. *
  579. * @since Twenty Seventeen 1.0
  580. */
  581. function simplenineteen_javascript_detection() {
  582. echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\n";
  583. }
  584. add_action( 'wp_head', 'simplenineteen_javascript_detection', 0 );
  585. /**
  586. * Add a pingback url auto-discovery header for singularly identifiable articles.
  587. */
  588. function simplenineteen_pingback_header() {
  589. if ( is_singular() && pings_open() ) {
  590. printf( '<link rel="pingback" href="%s">' . "\n", esc_url( get_bloginfo( 'pingback_url' ) ) );
  591. }
  592. }
  593. add_action( 'wp_head', 'simplenineteen_pingback_header' );
  594. /**
  595. * Display custom color CSS.
  596. */
  597. function simplenineteen_colors_css_wrap() {
  598. if ( 'custom' !== get_theme_mod( 'colorscheme' ) && ! is_customize_preview() ) {
  599. return;
  600. }
  601. require_once( get_parent_theme_file_path( '/inc/color-patterns.php' ) );
  602. $hue = absint( get_theme_mod( 'colorscheme_hue', 250 ) );
  603. $customize_preview_data_hue = '';
  604. if ( is_customize_preview() ) {
  605. $customize_preview_data_hue = 'data-hue="' . $hue . '"';
  606. }
  607. ?>
  608. <style type="text/css" id="custom-theme-colors" <?php echo $customize_preview_data_hue; ?>>
  609. <?php echo simplenineteen_custom_colors_css(); ?>
  610. </style>
  611. <?php
  612. }
  613. add_action( 'wp_head', 'simplenineteen_colors_css_wrap' );
  614. /**
  615. * Enqueues scripts and styles.
  616. */
  617. function simplenineteen_scripts() {
  618. // Theme stylesheet.
  619. wp_enqueue_style( 'simplenineteen-style', get_stylesheet_uri() );
  620. // Theme block stylesheet.
  621. wp_enqueue_style( 'simplenineteen-block-style', get_theme_file_uri( '/assets/css/blocks.css' ), array( 'simplenineteen-style' ), '1.1' );
  622. // Load the dark colorscheme.
  623. if ( 'dark' === get_theme_mod( 'colorscheme', 'light' ) || is_customize_preview() ) {
  624. wp_enqueue_style( 'simplenineteen-colors-dark', get_theme_file_uri( '/assets/css/colors-dark.css' ), array( 'simplenineteen-style' ), '1.0' );
  625. }
  626. if ( is_single() && simplenineteen_any_popup_modal_enabled() ) {
  627. wp_enqueue_style( 'simpleninteen-modal-share', get_theme_file_uri( '/assets/css/modal-share.css' ), array( 'simplenineteen-style' ), '1.1' );
  628. }
  629. // Load the Internet Explorer 9 specific stylesheet, to fix display issues in the Customizer.
  630. if ( is_customize_preview() ) {
  631. wp_enqueue_style( 'simplenineteen-ie9', get_theme_file_uri( '/assets/css/ie9.css' ), array( 'simplenineteen-style' ), '1.0' );
  632. wp_style_add_data( 'simplenineteen-ie9', 'conditional', 'IE 9' );
  633. }
  634. // Load the Internet Explorer 8 specific stylesheet.
  635. wp_enqueue_style( 'simplenineteen-ie8', get_theme_file_uri( '/assets/css/ie8.css' ), array( 'simplenineteen-style' ), '1.0' );
  636. wp_style_add_data( 'simplenineteen-ie8', 'conditional', 'lt IE 9' );
  637. // Load the html5 shiv.
  638. wp_enqueue_script( 'html5', get_theme_file_uri( '/assets/js/html5.js' ), array(), '3.7.3' );
  639. wp_script_add_data( 'html5', 'conditional', 'lt IE 9' );
  640. wp_enqueue_script( 'simplenineteen-skip-link-focus-fix', get_theme_file_uri( '/assets/js/skip-link-focus-fix.js' ), array(), '1.0', true );
  641. if ( is_single() && simplenineteen_any_popup_modal_enabled() ) {
  642. wp_enqueue_script( 'simplenineteen-modal-share', get_theme_file_uri( '/assets/js/modal-share.js' ), array(), '1.1', true );
  643. }
  644. if ( is_single() && simplenineteen_any_not_popup_modal_enabled() ) {
  645. wp_enqueue_script( 'simplenineteen-nonmodal-share', get_theme_file_uri( '/assets/js/nonmodal-share.js' ), array(), '1.0', true );
  646. }
  647. $simplenineteen_l10n = array(
  648. 'quote' => simplenineteen_get_svg( array( 'icon' => 'quote-right' ) ),
  649. );
  650. if ( has_nav_menu( 'top' ) ) {
  651. wp_enqueue_script( 'simplenineteen-navigation', get_theme_file_uri( '/assets/js/navigation.js' ), array( 'jquery' ), '1.0', true );
  652. $simplenineteen_l10n['expand'] = __( 'Expand child menu', 'simplenineteen' );
  653. $simplenineteen_l10n['collapse'] = __( 'Collapse child menu', 'simplenineteen' );
  654. $simplenineteen_l10n['icon'] = simplenineteen_get_svg(
  655. array(
  656. 'icon' => 'angle-down',
  657. 'fallback' => true,
  658. )
  659. );
  660. }
  661. wp_enqueue_script( 'simplenineteen-global', get_theme_file_uri( '/assets/js/global.js' ), array( 'jquery' ), '1.1', true );
  662. wp_enqueue_script( 'jquery-scrollto', get_theme_file_uri( '/assets/js/jquery.scrollTo.js' ), array( 'jquery' ), '2.1.2', true );
  663. wp_localize_script( 'simplenineteen-skip-link-focus-fix', 'simplenineteenScreenReaderText', $simplenineteen_l10n );
  664. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  665. wp_enqueue_script( 'comment-reply' );
  666. }
  667. }
  668. add_action( 'wp_enqueue_scripts', 'simplenineteen_scripts' );
  669. /**
  670. * Enqueues styles for the block-based editor.
  671. *
  672. * @since Twenty Seventeen 1.8
  673. */
  674. function simplenineteen_block_editor_styles() {
  675. // Block styles.
  676. wp_enqueue_style( 'simplenineteen-block-editor-style', get_theme_file_uri( '/assets/css/editor-blocks.css' ), array(), '1.1' );
  677. // Add custom fonts.
  678. }
  679. add_action( 'enqueue_block_editor_assets', 'simplenineteen_block_editor_styles' );
  680. /**
  681. * Add custom image sizes attribute to enhance responsive image functionality
  682. * for content images.
  683. *
  684. * @since Twenty Seventeen 1.0
  685. *
  686. * @param string $sizes A source size value for use in a 'sizes' attribute.
  687. * @param array $size Image size. Accepts an array of width and height
  688. * values in pixels (in that order).
  689. * @return string A source size value for use in a content image 'sizes' attribute.
  690. */
  691. function simplenineteen_content_image_sizes_attr( $sizes, $size ) {
  692. $width = $size[0];
  693. if ( 740 <= $width ) {
  694. $sizes = '(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px';
  695. }
  696. if ( is_active_sidebar( 'sidebar-1' ) || is_archive() || is_search() || is_home() || is_page() ) {
  697. if ( ! ( is_page() && 'one-column' === get_theme_mod( 'page_options' ) ) && 767 <= $width ) {
  698. $sizes = '(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px';
  699. }
  700. }
  701. return $sizes;
  702. }
  703. add_filter( 'wp_calculate_image_sizes', 'simplenineteen_content_image_sizes_attr', 10, 2 );
  704. /**
  705. * Filter the `sizes` value in the header image markup.
  706. *
  707. * @since Twenty Seventeen 1.0
  708. *
  709. * @param string $html The HTML image tag markup being filtered.
  710. * @param object $header The custom header object returned by 'get_custom_header()'.
  711. * @param array $attr Array of the attributes for the image tag.
  712. * @return string The filtered header image HTML.
  713. */
  714. function simplenineteen_header_image_tag( $html, $header, $attr ) {
  715. if ( isset( $attr['sizes'] ) ) {
  716. $html = str_replace( $attr['sizes'], '100vw', $html );
  717. }
  718. return $html;
  719. }
  720. add_filter( 'get_header_image_tag', 'simplenineteen_header_image_tag', 10, 3 );
  721. /**
  722. * Add custom image sizes attribute to enhance responsive image functionality
  723. * for post thumbnails.
  724. *
  725. * @since Twenty Seventeen 1.0
  726. *
  727. * @param array $attr Attributes for the image markup.
  728. * @param int $attachment Image attachment ID.
  729. * @param array $size Registered image size or flat array of height and width dimensions.
  730. * @return array The filtered attributes for the image markup.
  731. */
  732. function simplenineteen_post_thumbnail_sizes_attr( $attr, $attachment, $size ) {
  733. $attr['sizes'] = '100vw';
  734. return $attr;
  735. }
  736. add_filter( 'wp_get_attachment_image_attributes', 'simplenineteen_post_thumbnail_sizes_attr', 10, 3 );
  737. /**
  738. * Use front-page.php when Front page displays is set to a static page.
  739. *
  740. * @since Twenty Seventeen 1.0
  741. *
  742. * @param string $template front-page.php.
  743. *
  744. * @return string The template to be used: blank if is_home() is true (defaults to index.php), else $template.
  745. */
  746. function simplenineteen_front_page_template( $template ) {
  747. return is_home() ? '' : $template;
  748. }
  749. add_filter( 'frontpage_template', 'simplenineteen_front_page_template' );
  750. /**
  751. * Modifies tag cloud widget arguments to display all tags in the same font size
  752. * and use list format for better accessibility.
  753. *
  754. * @since Twenty Seventeen 1.4
  755. *
  756. * @param array $args Arguments for tag cloud widget.
  757. * @return array The filtered arguments for tag cloud widget.
  758. */
  759. function simplenineteen_widget_tag_cloud_args( $args ) {
  760. $args['largest'] = 1;
  761. $args['smallest'] = 1;
  762. $args['unit'] = 'em';
  763. $args['format'] = 'list';
  764. return $args;
  765. }
  766. add_filter( 'widget_tag_cloud_args', 'simplenineteen_widget_tag_cloud_args' );
  767. /**
  768. * Get unique ID.
  769. *
  770. * This is a PHP implementation of Underscore's uniqueId method. A static variable
  771. * contains an integer that is incremented with each call. This number is returned
  772. * with the optional prefix. As such the returned value is not universally unique,
  773. * but it is unique across the life of the PHP process.
  774. *
  775. * @since Simple Nineteen 1.0
  776. * @see wp_unique_id() Themes requiring WordPress 5.0.3 and greater should use this instead.
  777. *
  778. * @staticvar int $id_counter
  779. *
  780. * @param string $prefix Prefix for the returned ID.
  781. * @return string Unique ID.
  782. */
  783. function simplenineteen_unique_id( $prefix = '' ) {
  784. static $id_counter = 0;
  785. if ( function_exists( 'wp_unique_id' ) ) {
  786. return wp_unique_id( $prefix );
  787. }
  788. return $prefix . (string) ++$id_counter;
  789. }
  790. /**
  791. * Implement the Custom Header feature.
  792. */
  793. require get_parent_theme_file_path( '/inc/custom-header.php' );
  794. /**
  795. * Custom template tags for this theme.
  796. */
  797. require get_parent_theme_file_path( '/inc/template-tags.php' );
  798. /**
  799. * Additional features to allow styling of the templates.
  800. */
  801. require get_parent_theme_file_path( '/inc/template-functions.php' );
  802. /**
  803. * Customizer additions.
  804. */
  805. require get_parent_theme_file_path( '/inc/customizer.php' );
  806. /**
  807. * SVG icons functions and filters.
  808. */
  809. require get_parent_theme_file_path( '/inc/icon-functions.php' );
  810. /**
  811. * Enable or disable author pages functionality.
  812. */
  813. function redirect_author_page() {
  814. if ( is_author() && 'off' === get_theme_mod( 'author_pages' ) ) {
  815. global $wp_query;
  816. $wp_query->set_404();
  817. status_header( 404 );
  818. nocache_headers();
  819. }
  820. }
  821. add_action( 'template_redirect', 'redirect_author_page' );
  822. /**
  823. * 404 error page.
  824. */
  825. function simplenineteen_404_page() {
  826. if ( is_404() ) {
  827. if ( 'custom_page' === get_theme_mod( 'show_on_404' ) ) {
  828. $custom_page = get_post( get_theme_mod( 'custom_404_page' ) );
  829. $args = array(
  830. 'post_type' => $custom_page->post_type,
  831. 'page_id' => $custom_page->ID,
  832. 'pagename' => $custom_page->post_title,
  833. );
  834. query_posts( $args );
  835. wp_reset_postdata();
  836. } else if ( 'redirect' === get_theme_mod( 'show_on_404' ) ) {
  837. wp_redirect( get_permalink( get_theme_mod( 'custom_404_redirect' ) ) );
  838. }
  839. }
  840. }
  841. add_action( 'template_redirect', 'simplenineteen_404_page' );
  842. /**
  843. * Add custom checkbox to posts editor to enable or disable the display of a featured thumbnail.
  844. */
  845. function simplenineteen_add_custom_post_meta() {
  846. add_meta_box('simpleninteen-post-options', esc_html__( 'Simple Nineteen Options', 'simplenineteen'), 'simplenineteen_print_post_meta_box', 'post' );
  847. add_meta_box('simpleninteen-post-options', esc_html__( 'Simple Nineteen Options', 'simplenineteen'), 'simplenineteen_print_post_meta_box', 'page' );
  848. }
  849. add_action( 'add_meta_boxes', 'simplenineteen_add_custom_post_meta' );
  850. function simplenineteen_print_post_meta_box() {
  851. wp_nonce_field('simplenineteen-post-meta-box-save', 'simplenineteen-post-meta-box-nonce');
  852. ?>
  853. <p>
  854. <input type="checkbox" id="simplenineteen-featured-thumbnail-show" name="simplenineteen-feature-thumbnail-show-checkbox" value="1" <?php checked( get_post_meta( get_the_ID(), 'simplenineteen-featured-thumbnail-show', true ) ); ?> />
  855. <label for="simplenineteen-featured-thumbnail-show"><?php echo esc_html__( 'Show the Featured Thumbnail', 'simplenineteen' ); ?></label>
  856. </p>
  857. <?php
  858. $post_id = $_GET['post'];
  859. $front_page_id = get_option('page_on_front');
  860. $posts_page_id = get_option('page_for_posts');
  861. if ( $post_id != $front_page_id ) {
  862. ?>
  863. <p>
  864. <input type="checkbox" id="simplenineteen-no-page-title" name="simplenineteen-no-page-title-checkbox" value="1" <?php checked( get_post_meta( get_the_ID(), 'simplenineteen-no-page-title', true ) ); ?> />
  865. <label for="simplenineteen-no-page-title"><?php echo esc_html__( 'Don&#39;t show the page title', 'simplenineteen' ); ?></label>
  866. </p>
  867. <?php
  868. }
  869. if ( $post_id == $front_page_id ) {
  870. ?>
  871. <p>
  872. <input type="checkbox" id="simplenineteen-big-front-page-header" name="simplenineteen-big-front-page-header-checkbox" value="1" <?php checked( get_post_meta( get_the_ID(), 'simplenineteen-big-front-page-header', true ) ); ?> />
  873. <label for="simplenineteen-big-front-page-header"><?php echo esc_html__( 'Make the header big', 'simplenineteen' ); ?></label>
  874. </p>
  875. <?php
  876. }
  877. ?>
  878. <p id="simplenineteen-fullscreen-option">
  879. <input type="checkbox" id="simplenineteen-fullscreen" name="simplenineteen-fullscreen-checkbox" value="1" <?php checked( get_post_meta( get_the_ID(), 'simplenineteen-fullscreen', true ) ); ?> />
  880. <label for="simplenineteen-fullscreen"><?php echo esc_html__( 'Make the page full screen', 'simplenineteen' ); ?></label>
  881. </p>
  882. <p id="simplenineteen-show-logo-option" <?php if ( ! get_post_meta(get_the_ID(), 'simplenineteen-fullscreen', true) ) { ?> style="display: none;" <?php } ?> >
  883. <input type="checkbox" id="simplenineteen-show-logo" name="simplenineteen-logo-checkbox" value="1" <?php checked( get_post_meta( get_the_ID(), 'simplenineteen-show-logo', true ) ); ?> />
  884. <label for="simplenineteen-show-logo"><?php echo esc_html__( 'Show the site logo', 'simplenineteen' ); ?></label>
  885. </p>
  886. <p>
  887. <input type="checkbox" id="simplenineteen-fullwidth" name="simplenineteen-fullwidth-checkbox" value="1" <?php checked( get_post_meta( get_the_ID(), 'simplenineteen-fullwidth', true ) ); ?> />
  888. <label for="simplenineteen-fullwidth"><?php echo esc_html__( 'Make the page full width', 'simplenineteen' ); ?></label>
  889. </p>
  890. <?php
  891. $post_type = get_current_screen()->post_type;
  892. if ( $post_type == 'post' || $post_id == $posts_page_id ) {
  893. ?>
  894. <p>
  895. <input type="checkbox" id="simplenineteen-no-sidebar" name="simplenineteen-no-sidebar-checkbox" value="1" <?php checked( get_post_meta( get_the_ID(), 'simplenineteen-no-sidebar', true ) ); ?> />
  896. <label for="simplenineteen-no-sidebar"><?php echo esc_html__( 'Don&#39;t show the sidebar', 'simplenineteen' ); ?></label>
  897. </p>
  898. <?php
  899. }
  900. }
  901. function simplenineteen_save_custom_post_meta_data( $post_id ) {
  902. // Get the post type.
  903. $post_type = get_post_type( $post_id );
  904. // Check post ID and what the front page's post ID is.
  905. $front_page_id = get_option('page_on_front');
  906. // Say no to autosave, kids.
  907. if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
  908. return;
  909. }
  910. // Other security measures.
  911. if ( ! isset( $_POST['simplenineteen-post-meta-box-nonce'] ) || ! wp_verify_nonce( $_POST['simplenineteen-post-meta-box-nonce'], 'simplenineteen-post-meta-box-save' ) ) {
  912. return;
  913. }
  914. if ( ! current_user_can( 'edit_post', $post_id ) ) {
  915. return;
  916. }
  917. // Save featured thumbnail show checkbox setting
  918. if ( isset( $_POST[ 'simplenineteen-feature-thumbnail-show-checkbox' ] ) ) {
  919. update_post_meta( $post_id, 'simplenineteen-featured-thumbnail-show', 1 );
  920. } else {
  921. delete_post_meta( $post_id, 'simplenineteen-featured-thumbnail-show' );
  922. }
  923. // Save fullscreen checkbox setting
  924. if ( isset( $_POST[ 'simplenineteen-fullscreen-checkbox' ] ) ) {
  925. update_post_meta( $post_id, 'simplenineteen-fullscreen', 1 );
  926. } else {
  927. delete_post_meta( $post_id, 'simplenineteen-fullscreen' );
  928. }
  929. // Save fullwidth checkbox setting
  930. if ( isset( $_POST[ 'simplenineteen-fullwidth-checkbox' ] ) ) {
  931. update_post_meta( $post_id, 'simplenineteen-fullwidth', 1 );
  932. } else {
  933. delete_post_meta( $post_id, 'simplenineteen-fullwidth' );
  934. }
  935. // Save show logo checkbox (option is only available when fullscreen is enabled for the post or page)
  936. if ( isset( $_POST[ 'simplenineteen-fullscreen-checkbox' ] ) && isset( $_POST[ 'simplenineteen-logo-checkbox' ] ) ) {
  937. update_post_meta( $post_id, 'simplenineteen-show-logo', 1 );
  938. } else {
  939. delete_post_meta( $post_id, 'simplenineteen-show-logo' );
  940. }
  941. // Save no sidebar checkbox setting
  942. if ( isset( $_POST[ 'simplenineteen-no-sidebar-checkbox' ] ) && $post_type == 'post' ) {
  943. update_post_meta( $post_id, 'simplenineteen-no-sidebar', 1 );
  944. } else {
  945. delete_post_meta( $post_id, 'simplenineteen-no-sidebar' );
  946. }
  947. // Save no page title setting
  948. if ( isset( $_POST[ 'simplenineteen-no-page-title-checkbox' ] ) && $post_id != $front_page_id ) {
  949. update_post_meta( $post_id, 'simplenineteen-no-page-title', 1 );
  950. } else {
  951. delete_post_meta( $post_id, 'simplenineteen-no-page-title' );
  952. }
  953. // Save the big front page header setting
  954. if ( isset( $_POST['simplenineteen-big-front-page-header-checkbox' ] ) && $post_id == $front_page_id ) {
  955. update_post_meta( $post_id, 'simplenineteen-big-front-page-header', 1 );
  956. } else {
  957. delete_post_meta( $post_id, 'simplenineteen-big-front-page-header' );
  958. }
  959. }
  960. add_action( 'save_post', 'simplenineteen_save_custom_post_meta_data' );
  961. /**
  962. * Enqueue the admin edit post/page styles and scripts.
  963. */
  964. function simplenineteen_enqueue_admin_edit_script( $hook ) {
  965. if ( 'post.php' == $hook ) {
  966. wp_enqueue_script( 'simplenineteen-admin-edit', get_theme_file_uri( '/assets/js/admin-edit.js' ), array(), '1.0', true );
  967. wp_enqueue_style( 'simplenineteen-admin-edit', get_theme_file_uri( '/assets/css/admin-edit.css' ), array(), '1.0' );
  968. }
  969. }
  970. add_action( 'admin_enqueue_scripts', 'simplenineteen_enqueue_admin_edit_script' );
  971. /**
  972. * Function to get the list of platforms that Simple Nineteen has share button support for.
  973. */
  974. function simplenineteen_share_platforms() {
  975. return array(
  976. array(
  977. 'title' => 'Mastodon',
  978. 'slug' => 'mastodon',
  979. 'popup' => true,
  980. 'example' => 'https://gameliberty.club',
  981. 'url_before_args' => 'share?text=',
  982. 'hashtags' => true,
  983. 'author' => true,
  984. ),
  985. array(
  986. 'title' => 'Pleroma',
  987. 'slug' => 'pleroma',
  988. 'popup' => true,
  989. 'example' => 'https://freespeechextremist.com',
  990. 'url_before_args' => '?message=',
  991. 'hashtags' => true,
  992. 'author' => true,
  993. ),
  994. array(
  995. 'title' => 'GNU Social',
  996. 'slug' => 'gnusocial',
  997. 'popup' => true,
  998. 'example' => 'https://gnusocial.no',
  999. 'url_before_args' => 'notice/new?status_textarea=',
  1000. 'hashtags' => true,
  1001. 'author' => true,
  1002. ),
  1003. array(
  1004. 'title' => 'Throat',
  1005. 'slug' => 'throat',
  1006. 'popup' => true,
  1007. 'example' => 'https://poal.co',
  1008. 'url_before_args' => 'submit/link?title=',
  1009. 'before_url_param' => '&url=',
  1010. 'hashtags' => false,
  1011. 'author' => false,
  1012. ),
  1013. array(
  1014. 'title' => 'Email',
  1015. 'slug' => 'email',
  1016. 'popup' => false,
  1017. 'url_before_args' => 'mailto:?subject=',
  1018. 'hashtags' => false,
  1019. 'author' => false,
  1020. 'title_in_link' => true,
  1021. 'before_url_param' => '&body=',
  1022. ),
  1023. array(
  1024. 'title' => 'Telegram',
  1025. 'slug' => 'telegram',
  1026. 'popup' => false,
  1027. 'url_before_args' => 'https://telegram.me/share/url?text=',
  1028. 'hashtags' => false,
  1029. 'author' => false,
  1030. 'title_in_link' => true,
  1031. 'before_url_param' => '&url=',
  1032. ),
  1033. array(
  1034. 'title' => 'MeWe',
  1035. 'slug' => 'mewe',
  1036. 'popup' => false,
  1037. 'url_before_args' => 'https://mewe.com/share?link=',
  1038. 'hashtags' => false,
  1039. 'author' => false,
  1040. 'title_in_link' => false,
  1041. ),
  1042. array(
  1043. 'title' => 'Pocket',
  1044. 'slug' => 'pocket',
  1045. 'popup' => false,
  1046. 'url_before_args' => 'https://getpocket.com/save?title=',
  1047. 'hashtags' => false,
  1048. 'author' => false,
  1049. 'title_in_link' => true,
  1050. 'before_url_param' => '&url=',
  1051. ),
  1052. array(
  1053. 'title' => 'Twitter',
  1054. 'slug' => 'twtr',
  1055. 'popup' => false,
  1056. 'url_before_args' => 'https://twitter.com/intent/tweet?text=',
  1057. 'hashtags' => true,
  1058. 'author' => true,
  1059. 'title_in_link' => true,
  1060. 'author_placeholder' => '@SandiaMesa',
  1061. ),
  1062. array(
  1063. 'title' => 'Reddit',
  1064. 'slug' => 'reddit',
  1065. 'popup' => false,
  1066. 'url_before_args' => 'https://www.reddit.com/submit?title=',
  1067. 'hashtags' => false,
  1068. 'author' => false,
  1069. 'title_in_link' => true,
  1070. 'before_url_param' => '&url=',
  1071. ),
  1072. array(
  1073. 'title' => 'VK',
  1074. 'slug' => 'vk',
  1075. 'popup' => false,
  1076. 'url_before_args' => 'https://vk.com/share.php?url=',
  1077. 'hashtags' => false,
  1078. 'author' => false,
  1079. 'title_in_link' => false,
  1080. ),
  1081. array(
  1082. 'title' => 'Facebook',
  1083. 'slug' => 'fb',
  1084. 'popup' => false,
  1085. 'url_before_args' => 'https://facebook.com/sharer/sharer.php?u=',
  1086. 'hashtags' => false,
  1087. 'author' => false,
  1088. 'title_in_link' => false,
  1089. ),
  1090. );
  1091. }
  1092. /**
  1093. * Confirm password.
  1094. */
  1095. function wpum_my_psw_field_confirmation( $fields ) {
  1096. $fields[ 'confirm_psw' ] = array(
  1097. 'label' => 'Confirm password',
  1098. 'type' => 'password',
  1099. 'meta' => false,
  1100. 'required' => true,
  1101. 'priority' => 30
  1102. );
  1103. return $fields;
  1104. }
  1105. add_filter( 'wpum_get_registration_fields', 'wpum_my_psw_field_confirmation' );
  1106. function wpum_verify_my_psw_confirmation( $pass, $fields, $values, $form ) {
  1107. if ( $form === 'registration' && isset( $values['register']['confirm_psw'] ) ) {
  1108. $psw1 = $values['register']['user_password'];
  1109. $psw2 = $values['register']['confirm_psw'];
  1110. if ( $psw1 !== $psw2 ) {
  1111. return new WP_Error( 'psw-validation-error', 'Passwords do not match.' );
  1112. }
  1113. }
  1114. return $pass;
  1115. }
  1116. add_filter( 'submit_wpum_form_validate_fields', 'wpum_verify_my_psw_confirmation', 10, 4 );
  1117. // Function to handle the thumbnail request
  1118. function get_the_post_thumbnail_src($img)
  1119. {
  1120. return (preg_match('~\bsrc="([^"]++)"~', $img, $matches)) ? $matches[1] : '';
  1121. }
  1122. //This is the consent checkbox for Privacy
  1123. add_filter(
  1124. 'wpum_privacy_text',
  1125. function( $text ) {
  1126. return 'I give Sandia Mesa Animation Studios my consent to use this information for the purposes specifically outlined in the <a href="/privacy-policy">Privacy Policy</a>.';
  1127. }
  1128. );
  1129. //This is the terms of service checbox
  1130. add_filter(
  1131. 'wpum_terms_text',
  1132. function( $text ) {
  1133. return 'I agree to the <a href="/tos">Terms of Service</a>.';
  1134. }
  1135. );
  1136. //Remove WP Emoji canvas fingerprinting code bloat
  1137. remove_action('wp_head', 'print_emoji_detection_script', 7);
  1138. remove_action('admin_print_scripts', 'print_emoji_detection_script');
  1139. remove_action('wp_print_styles', 'print_emoji_styles');
  1140. remove_action('admin_print_styles', 'print_emoji_styles');
  1141. add_filter('emoji_svg_url', '__return_false');