Skip to content

Commit d9ace5d

Browse files
committed
Add visibilities
1 parent 6391b8c commit d9ace5d

3 files changed

Lines changed: 30 additions & 30 deletions

File tree

classes/class-cpt-wplf-form.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public static function register_cpt() {
104104
/**
105105
* Modify post.php permalink html to show notice if form isn't publicly visible.
106106
*/
107-
function modify_permalink_html( $html, $post_id ) {
107+
public function modify_permalink_html( $html, $post_id ) {
108108
$publicly_visible = $this->get_publicly_visible_state( $post_id );
109109

110110
if ( get_post_type( $post_id ) === 'wplf-form' && ! $publicly_visible ) {
@@ -119,7 +119,7 @@ function modify_permalink_html( $html, $post_id ) {
119119
/**
120120
* Disable TinyMCE editor for forms, which are simple HTML things
121121
*/
122-
function disable_tinymce( $default ) {
122+
public function disable_tinymce( $default ) {
123123
global $post;
124124

125125
// only for this cpt
@@ -133,7 +133,7 @@ function disable_tinymce( $default ) {
133133
/**
134134
* Include custom JS on the edit screen
135135
*/
136-
function admin_post_scripts_cpt( $hook ) {
136+
public function admin_post_scripts_cpt( $hook ) {
137137
global $post;
138138

139139
// make sure we're on the correct view
@@ -154,7 +154,7 @@ function admin_post_scripts_cpt( $hook ) {
154154
/**
155155
* Pre-populate form editor with default content
156156
*/
157-
function default_content_cpt( $content ) {
157+
public function default_content_cpt( $content ) {
158158
global $pagenow;
159159

160160
// only on post.php screen
@@ -205,7 +205,7 @@ function remove_row_actions( $actions, $post ) {
205205
/**
206206
* Custom columns in edit.php for Forms
207207
*/
208-
function custom_columns_cpt( $columns ) {
208+
public function custom_columns_cpt( $columns ) {
209209
$new_columns = array(
210210
'cb' => $columns['cb'],
211211
'title' => $columns['title'],
@@ -220,7 +220,7 @@ function custom_columns_cpt( $columns ) {
220220
/**
221221
* Custom column display for Form CPT in edit.php
222222
*/
223-
function custom_columns_display_cpt( $column, $post_id ) {
223+
public function custom_columns_display_cpt( $column, $post_id ) {
224224
if ( 'shortcode' === $column ) {
225225
?>
226226
<input type="text" class="code" value='[libre-form id="<?php echo intval( $post_id ); ?>"]' readonly>
@@ -247,7 +247,7 @@ function custom_columns_display_cpt( $column, $post_id ) {
247247
/**
248248
* Add meta box to show fields in form
249249
*/
250-
function add_meta_boxes_cpt() {
250+
public function add_meta_boxes_cpt() {
251251
// Shortcode meta box
252252
add_meta_box(
253253
'wplf-shortcode',
@@ -301,7 +301,7 @@ function add_meta_boxes_cpt() {
301301
/**
302302
* Meta box callback for shortcode meta box
303303
*/
304-
function metabox_shortcode( $post ) {
304+
public function metabox_shortcode( $post ) {
305305
?>
306306
<p><input type="text" class="code" value='[libre-form id="<?php echo esc_attr( $post->ID ); ?>"]' readonly></p>
307307
<?php
@@ -333,7 +333,7 @@ function metabox_thank_you( $post ) {
333333
/**
334334
* Meta box callback for form fields meta box
335335
*/
336-
function metabox_form_fields() {
336+
public function metabox_form_fields() {
337337
?>
338338
<p><?php esc_html_e( 'Fields marked with * are required', 'wp-libre-form' ); ?></p>
339339
<div class="wplf-form-field-container">
@@ -347,7 +347,7 @@ function metabox_form_fields() {
347347
/**
348348
* Meta box callback for submit email meta box
349349
*/
350-
function metabox_submit_email( $post ) {
350+
public function metabox_submit_email( $post ) {
351351
// get post meta
352352
$meta = get_post_meta( $post->ID );
353353
$email_enabled = isset( $meta['_wplf_email_copy_enabled'] ) ? $meta['_wplf_email_copy_enabled'][0] : true;
@@ -438,7 +438,7 @@ function metabox_submit_email( $post ) {
438438
/**
439439
* Meta box callback for submission title format
440440
*/
441-
function meta_box_title_format( $post ) {
441+
public function meta_box_title_format( $post ) {
442442
// get post meta
443443
$meta = get_post_meta( $post->ID );
444444
$default = '%name% <%email%>'; // default submission title format
@@ -463,7 +463,7 @@ class="code"
463463
/**
464464
* Handles saving our post meta
465465
*/
466-
function save_cpt( $post_id ) {
466+
public function save_cpt( $post_id ) {
467467
// verify nonce
468468
if ( ! isset( $_POST['wplf_form_meta_nonce'] ) ) {
469469
return;
@@ -577,15 +577,15 @@ function save_cpt( $post_id ) {
577577
*
578578
* We apply <form> via the shortcode, you can't have nested forms anyway
579579
*/
580-
function strip_form_tags( $content ) {
580+
public function strip_form_tags( $content ) {
581581
return preg_replace( '/<\/?form.*>/i', '', $content );
582582
}
583583

584584

585585
/**
586586
* The function we display the form with
587587
*/
588-
function wplf_form( $id, $content = '', $xclass = '', $attributes = [] ) {
588+
public function wplf_form( $id, $content = '', $xclass = '', $attributes = [] ) {
589589
global $post;
590590

591591
if ( 'publish' === get_post_status( $id ) || 'true' === $_GET['preview'] ) {
@@ -663,7 +663,7 @@ class="libre-form libre-form-<?php echo esc_attr( $id . ' ' . $xclass ); ?>"
663663
/**
664664
* Enqueue the front end JS
665665
*/
666-
function maybe_enqueue_frontend_script() {
666+
public function maybe_enqueue_frontend_script() {
667667
global $post;
668668

669669
// register the script, but only enqueue it if the current post contains a form in it
@@ -687,7 +687,7 @@ function maybe_enqueue_frontend_script() {
687687
/**
688688
* Shortcode for displaying a Form
689689
*/
690-
function shortcode( $shortcode_atts, $content = null ) {
690+
public function shortcode( $shortcode_atts, $content = null ) {
691691
$attributes = shortcode_atts( array(
692692
'id' => null,
693693
'xclass' => '',
@@ -709,7 +709,7 @@ function shortcode( $shortcode_atts, $content = null ) {
709709
/**
710710
* Use the shortcode for previewing forms
711711
*/
712-
function use_shortcode_for_preview( $content ) {
712+
public function use_shortcode_for_preview( $content ) {
713713
global $post;
714714
if ( ! isset( $post->post_type ) || $post->post_type !== 'wplf-form' ) {
715715
return $content;
@@ -721,7 +721,7 @@ function use_shortcode_for_preview( $content ) {
721721
* Set and show 404 page for visitors trying to see single form.
722722
* And yes, it is a global $post. That's right.
723723
*/
724-
function maybe_set_404_for_single_form() {
724+
public function maybe_set_404_for_single_form() {
725725
global $post;
726726

727727
if ( ! is_singular( 'wplf-form' ) ) {
@@ -742,14 +742,14 @@ function maybe_set_404_for_single_form() {
742742
/**
743743
* Wrapper function to check if form is publicly visible.
744744
*/
745-
function get_publicly_visible_state( $id ) {
745+
public function get_publicly_visible_state( $id ) {
746746
return apply_filters( 'wplf-form-publicly-visible', false, $id );
747747
}
748748

749749
/**
750750
* A very simple uglify. Just removes line breaks from html
751751
*/
752-
function minify_html( $html ) {
752+
public function minify_html( $html ) {
753753
return str_replace( array( "\n", "\r" ), ' ', $html );
754754
}
755755
}

classes/class-cpt-wplf-submission.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static function register_cpt() {
7878
/**
7979
* Custom column display for Submission CPT in edit.php
8080
*/
81-
function custom_columns_display_cpt( $column, $post_id ) {
81+
public function custom_columns_display_cpt( $column, $post_id ) {
8282
if ( 'referrer' === $column ) {
8383
if ( $referrer = get_post_meta( $post_id, 'referrer', true ) ) {
8484
echo '<a href="' . esc_url_raw( $referrer ) . '">' . esc_url( $referrer ) . '</a>';
@@ -97,7 +97,7 @@ function custom_columns_display_cpt( $column, $post_id ) {
9797
/**
9898
* Custom columns in edit.php for Forms
9999
*/
100-
function custom_columns_cpt( $columns ) {
100+
public function custom_columns_cpt( $columns ) {
101101
$new_columns = array(
102102
'cb' => $columns['cb'],
103103
'title' => $columns['title'],
@@ -111,7 +111,7 @@ function custom_columns_cpt( $columns ) {
111111
/**
112112
* Show a form filter in the edit.php view
113113
*/
114-
function form_filter_dropdown() {
114+
public function form_filter_dropdown() {
115115
global $pagenow;
116116

117117
$allowed = array( 'wplf-submission' ); // show filter on these post types (currently only one?)
@@ -152,7 +152,7 @@ function form_filter_dropdown() {
152152
/**
153153
* Filter by form in the edit.php view
154154
*/
155-
function filter_by_form( $query ) {
155+
public function filter_by_form( $query ) {
156156
global $pagenow;
157157

158158
if ( 'edit.php' !== $pagenow ) {
@@ -171,12 +171,12 @@ function filter_by_form( $query ) {
171171
return $query;
172172
}
173173

174-
function register_wplf_submission_bulk_actions( $bulk_actions ) {
174+
public function register_wplf_submission_bulk_actions( $bulk_actions ) {
175175
$bulk_actions['wplf_resend_copy'] = __( 'Resend email copy', 'wp-libre-form' );
176176
return $bulk_actions;
177177
}
178178

179-
function wplf_submission_bulk_action_handler( $redirect_to, $doaction, $post_ids ) {
179+
public function wplf_submission_bulk_action_handler( $redirect_to, $doaction, $post_ids ) {
180180
if ( $doaction !== 'wplf_resend_copy' ) {
181181
return $redirect_to;
182182
}
@@ -192,7 +192,7 @@ function wplf_submission_bulk_action_handler( $redirect_to, $doaction, $post_ids
192192
return $redirect_to;
193193
}
194194

195-
function wplf_submission_bulk_action_admin_notice() {
195+
public function wplf_submission_bulk_action_admin_notice() {
196196
if ( ! empty( $_REQUEST['wplf_resent'] ) ) {
197197
$count = intval( $_REQUEST['wplf_resent'] );
198198
printf(
@@ -213,7 +213,7 @@ function wplf_submission_bulk_action_admin_notice() {
213213
/**
214214
* Add meta box to show fields in form
215215
*/
216-
function add_meta_boxes_cpt() {
216+
public function add_meta_boxes_cpt() {
217217
// Shortcode meta box
218218
add_meta_box(
219219
'wplf-shortcode',
@@ -228,7 +228,7 @@ function add_meta_boxes_cpt() {
228228
/**
229229
* The submission metabox callback
230230
*/
231-
function metabox_submission() {
231+
public function metabox_submission() {
232232
global $post;
233233
$postmeta = get_post_meta( $post->ID );
234234
$fields = array_keys( $postmeta );

classes/class-wplf-polylang.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function render_form( $form_content ) {
4242
return $form_content;
4343
}
4444

45-
function save_form( $post_id, $post, $update ) {
45+
public function save_form( $post_id, $post, $update ) {
4646
unset( $post_id, $update ); // not used here so shut up linter!
4747

4848
preg_match_all( $this->regular_expression, $post->post_content, $matches );

0 commit comments

Comments
 (0)