PluginProbe
WPSSO Core – Complete Schema Markup and Meta Tags / 22.7.0
WPSSO Core – Complete Schema Markup and Meta Tags v22.7.0
22.7.0 22.6.1 22.6.0 22.5.3 22.5.2 22.5.1 22.4.0 22.3.0 22.2.1 22.2.0 22.1.3 22.1.2 22.1.1 22.1.0 22.0.0 21.13.3 21.13.2 trunk 21.13.1
wpsso / lib / integ / form / gravityview.php

gravityview.php in WPSSO Core – Complete Schema Markup and Meta Tags 22.7.0, at lib/integ/form/gravityview.php

211 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * License: GPLv3
4 * License URI: https://www.gnu.org/licenses/gpl.txt
5 * Copyright 2012-2026 Jean-Sebastien Morisset (https://wpsso.com/)
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9
10 die( 'These aren\'t the droids you\'re looking for.' );
11 }
12
13 if ( ! class_exists( 'WpssoIntegFormGravityview' ) ) {
14
15 class WpssoIntegFormGravityview {
16
17 private $p; // Wpsso class object.
18
19 public function __construct( &$plugin ) {
20
21 $this->p =& $plugin;
22
23 if ( $this->p->debug->enabled ) {
24
25 $this->p->debug->mark();
26 }
27
28 $this->p->util->add_plugin_filters( $this, array(
29 'post_url' => 2,
30 'title_seed' => 5,
31 'description_seed' => 4,
32 'post_image_urls' => 4,
33 ) );
34
35 if ( is_admin() ) {
36
37 /*
38 * The 'add_meta_boxes' action fires after all built-in meta boxes have been added.
39 */
40 add_action( 'add_meta_boxes', array( $this, 'add_metabox_gravityview_integration' ) );
41
42 add_action( 'gravityview_noconflict_styles', array( $this, 'cleanup_gform_noconflict_styles' ) );
43 add_action( 'gravityview_noconflict_scripts', array( $this, 'cleanup_gform_noconflict_scripts' ) );
44 }
45 }
46
47 public function filter_post_url( $url, $mod ) {
48
49 if ( $entry_id = gravityview_is_single_entry() ) {
50
51 $var_name = \GV\Entry::get_endpoint_name();
52
53 if ( false !== strpos( $url, '?' ) ) {
54
55 return add_query_arg( $var_name, $entry_id, $url );
56
57 }
58
59 return trailingslashit( $url ) . $var_name . '/' . $entry_id . '/';
60 }
61
62 return $url;
63 }
64
65 public function filter_title_seed( $title_text, $mod, $num_hashtags, $md_key, $title_sep ) {
66
67 if ( $entry_id = gravityview_is_single_entry() ) {
68
69 $opts = $mod[ 'obj' ]->get_options( $mod[ 'id' ] );
70
71 if ( ! empty( $opts[ 'gv_id_title' ] ) ) {
72
73 $entry = gravityview_get_entry( $entry_id );
74
75 if ( isset( $entry[ $opts[ 'gv_id_title' ] ] ) ) {
76
77 return $entry[ $opts[ 'gv_id_title' ] ];
78 }
79 }
80 }
81
82 return $title_text;
83 }
84
85 public function filter_description_seed( $desc_text, $mod, $num_hashtags, $md_key ) {
86
87 if ( $entry_id = gravityview_is_single_entry() ) {
88
89 $opts = $mod[ 'obj' ]->get_options( $mod[ 'id' ] );
90
91 if ( ! empty( $opts[ 'gv_id_desc' ] ) ) {
92
93 $entry = gravityview_get_entry( $entry_id );
94
95 if ( isset( $entry[ $opts[ 'gv_id_desc' ] ] ) ) {
96
97 return $entry[ $opts[ 'gv_id_desc' ] ];
98 }
99 }
100 }
101
102 return $desc_text;
103 }
104
105 public function filter_post_image_urls( $urls, $size_name, $post_id, $mod ) {
106
107 if ( $entry_id = gravityview_is_single_entry() ) {
108
109 $opts = $mod[ 'obj' ]->get_options( $mod[ 'id' ] );
110
111 if ( ! empty( $opts[ 'gv_id_img' ] ) ) {
112
113 $entry = gravityview_get_entry( $entry_id );
114
115 if ( isset( $entry[ $opts[ 'gv_id_img' ] ] ) ) {
116
117 list( $img_url, $img_title, $img_caption, $img_desc ) = array_pad( explode( '|:|', $entry[ $opts[ 'gv_id_img' ] ] ), 4, false );
118
119 if ( ! empty( $img_url ) ) {
120
121 $urls[] = $img_url;
122
123 return $urls;
124 }
125 }
126 }
127 }
128
129 return $urls;
130 }
131
132 public function add_metabox_gravityview_integration() {
133
134 if ( ! is_admin() ) { // just in case
135
136 return;
137 }
138
139 $metabox_id = 'gravityview_integration';
140 $metabox_title = _x( 'Single Entry Integration', 'metabox title', 'wpsso' );
141 $metabox_screen = 'gravityview';
142 $metabox_context = 'side';
143 $metabox_prio = 'high';
144 $callback_args = array( // Second argument passed to the callback function / method.
145 '__block_editor_compatible_meta_box' => true,
146 );
147
148 add_meta_box( '_wpsso_' . $metabox_id, $metabox_title,
149 array( $this, 'show_metabox_gravityview_integration' ), $metabox_screen,
150 $metabox_context, $metabox_prio, $callback_args );
151 }
152
153 public function show_metabox_gravityview_integration( $post_obj ) {
154
155 if ( $this->p->debug->enabled ) {
156
157 $this->p->debug->mark();
158 }
159
160 $mod = $this->p->post->get_mod( $post_obj->ID );
161 $opts = $mod[ 'obj' ]->get_options( $mod[ 'id' ] );
162 $defs = $mod[ 'obj' ]->get_defaults( $mod[ 'id' ] );
163 $form = new SucomForm( $this->p, WPSSO_META_NAME, $opts, $defs, $this->p->id );
164
165 echo '<table class="sucom-settings wpsso post-side-metabox">';
166 echo '<tr>';
167 echo $form->get_th_html( _x( 'Title Field ID', 'option label', 'wpsso' ) );
168 echo '<td>' . $form->get_input( 'gv_id_title', 'short', '', 0, true ) . '</td>';
169 echo '</tr>';
170 echo '<tr>';
171 echo $form->get_th_html( _x( 'Description Field ID', 'option label', 'wpsso' ) );
172 echo '<td>' . $form->get_input( 'gv_id_desc', 'short', '', 0, true ) . '</td>';
173 echo '</tr>';
174 echo '<tr>';
175 echo $form->get_th_html( _x( 'Post Image Field ID', 'option label', 'wpsso' ) );
176 echo '<td>' . $form->get_input( 'gv_id_img', 'short', '', 0, true ) . '</td>';
177 echo '</tr>';
178 echo '</table>';
179 }
180
181 public function cleanup_gform_noconflict_styles( $styles ) {
182
183 return array_merge( $styles, array(
184 'jquery-ui.js',
185 'jquery-qtip.js',
186 'sucom-metabox-tabs',
187 'sucom-settings-page',
188 'sucom-settings-table',
189 'wp-color-picker',
190 'wpsso-admin-page',
191 ) );
192 }
193
194 public function cleanup_gform_noconflict_scripts( $scripts ) {
195
196 return array_merge( $scripts, array(
197 'jquery-ui-datepicker',
198 'jquery-qtip',
199 'sucom-admin-media',
200 'sucom-admin-page',
201 'sucom-metabox',
202 'sucom-settings-page',
203 'sucom-tooltips',
204 'wp-color-picker',
205 'wpsso-metabox',
206 'wpsso-block-editor',
207 ) );
208 }
209 }
210 }
211