GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
class-gravityview-plugin-hooks-yoast-seo.php
Go to the documentation of this file.
1 <?php
2 /**
3  * Add Yoast SEO scripts and styles to GravityView no-conflict list
4  *
5  * @file class-gravityview-plugin-hooks-yoast-seo.php
6  * @package GravityView
7  * @license GPL2+
8  * @author GravityView <[email protected]>
9  * @link http://gravityview.co
10  * @copyright Copyright 2015, Katz Web Services, Inc.
11  *
12  * @since 1.15.2
13  */
14 
15 /**
16  * @inheritDoc
17  * @since 1.15.2
18  */
20 
21  /**
22  * @inheritDoc
23  * @since 1.15.2
24  */
25  protected $constant_name = 'WPSEO_FILE';
26 
27  protected $style_handles = array(
28  'wp-seo-metabox',
29  'wpseo-admin-media',
30  'yoast-seo-admin-media',
31  'yoast-seo-snippet',
32  'yoast-seo-kb-search',
33  'metabox-tabs',
34  'metabox-classic',
35  'metabox-fresh',
36  // Yoast 14.7
37  'yoast-seo-admin-css',
38  'yoast-seo-admin-global',
39  'yoast-seo-adminbar',
40  'yoast-seo-alert',
41  'yoast-seo-dismissible',
42  'yoast-seo-edit-page',
43  'yoast-seo-extensions',
44  'yoast-seo-featured-image',
45  'yoast-seo-filter-explanation',
46  'yoast-seo-metabox-css',
47  'yoast-seo-monorepo',
48  'yoast-seo-notifications',
49  'yoast-seo-primary-category',
50  'yoast-seo-scoring',
51  'yoast-seo-search-appearance',
52  'yoast-seo-select2',
53  'yoast-seo-structured-data-blocks',
54  'yoast-seo-toggle-switch',
55  'yoast-seo-wp-dashboard',
56  'yoast-seo-yoast-components',
57  );
58 
59  /**
60  * @inheritDoc
61  * @since 1.15.2
62  */
63  protected $script_handles = array(
64  'wp-seo-metabox',
65  'wpseo-admin-media',
66  'yoast-seo-metabox',
67  'yoast-seo-admin-media',
68  'yoast-seo-post-scraper',
69  'yoast-seo-replacevar-plugin',
70  'yoast-seo-shortcode-plugin',
71  'jquery-qtip',
72  'jquery-ui-autocomplete',
73  'yoast-seo-admin-media',
74  'yoast-seo-admin-script',
75  // Yoast 14.7
76  'yoast-seo-admin-global-script',
77  'yoast-seo-analysis',
78  'yoast-seo-api',
79  'yoast-seo-bulk-editor',
80  'yoast-seo-commons',
81  'yoast-seo-components',
82  'yoast-seo-configuration-wizard',
83  'yoast-seo-dashboard-widget',
84  'yoast-seo-draft-js',
85  'yoast-seo-edit-page-script',
86  'yoast-seo-filter-explanation',
87  'yoast-seo-help-scout-beacon',
88  'yoast-seo-indexation',
89  'yoast-seo-jed',
90  'yoast-seo-network-admin-script',
91  'yoast-seo-post-edit',
92  'yoast-seo-quick-edit-handler',
93  'yoast-seo-recalculate',
94  'yoast-seo-redux',
95  'yoast-seo-reindex-links',
96  'yoast-seo-search-appearance',
97  'yoast-seo-select2',
98  'yoast-seo-select2-translations',
99  'yoast-seo-settings',
100  'yoast-seo-structured-data-blocks',
101  'yoast-seo-styled-components',
102  'yoast-seo-term-edit',
103  'yoast-seo-yoast-modal',
104  // Yoast 14.8
105  'yoast-seo-post-edit-classic',
106  );
107 
108  /**
109  * @inheritDoc
110  * @copydoc GravityView_Plugin_and_Theme_Hooks::add_hooks()
111  * @since 1.15.2
112  */
113  protected function add_hooks() {
114 
115  parent::add_hooks();
116 
117  if( gravityview()->request->is_admin( '', null ) ) {
118 
119  // Make Yoast metabox go down to the bottom please.
120  add_filter( 'wpseo_metabox_prio', array( $this, 'return_low' ) );
121 
122  // Prevent the SEO from being checked. Eesh.
123  add_filter( 'wpseo_use_page_analysis', '__return_false' );
124 
125  add_filter( 'option_wpseo', array( $this, 'disable_content_analysis' ) );
126 
127  // WordPress SEO Plugin
128  add_filter( 'option_wpseo_titles', array( $this, 'hide_wordpress_seo_metabox' ) );
129  }
130  }
131 
132  /**
133  * Don't try to analyze content for Views
134  *
135  * @since 1.22.4
136  * @param array $options Existing WPSEO options array
137  *
138  * @return array
139  */
140  public function disable_content_analysis( $options ) {
141 
142  $options['keyword_analysis_active'] = false;
143  $options['content_analysis_active'] = false;
144 
145  return $options;
146  }
147 
148  /**
149  * Modify the WordPress SEO plugin's metabox behavior
150  *
151  * Only show when the View has been configured.
152  *
153  * @since 1.15.2 Moved from class-gravityview-admin-metaboxes.php
154  *
155  * @param array $options WP SEO options array
156  * @return array Modified array if on post-new.php
157  */
158  public function hide_wordpress_seo_metabox( $options = array() ) {
159  global $pagenow;
160 
161  // New View page
162  if( $pagenow === 'post-new.php' ) {
163  $options['hideeditbox-gravityview'] = true;
164  }
165 
166  return $options;
167  }
168 
169  /**
170  * Return 'low' as the status for metabox priority when on a GravityView post type admin screen
171  *
172  * @since 1.15.2 Moved from class-gravityview-admin-metaboxes.php
173  * @since 1.15.2 Added check for GravityView post type
174  *
175  * @param string $existing Existing priority. Default: `high`
176  * @return string Returns 'low'
177  */
178  function return_low( $existing = 'high' ) {
179  return 'low';
180  }
181 }
182 
return_low( $existing='high')
Return &#39;low&#39; as the status for metabox priority when on a GravityView post type admin screen...
disable_content_analysis( $options)
Don&#39;t try to analyze content for Views.
gravityview()
The main GravityView wrapper function.
Abstract class that makes it easy for plugins and themes to register no-conflict scripts and styles...
hide_wordpress_seo_metabox( $options=array())
Modify the WordPress SEO plugin&#39;s metabox behavior.