PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.8.2
Kubio AI Page Builder v2.8.2
2.8.4 2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / lib / recommendations / recommendation-page-post-type.php
kubio / lib / recommendations Last commit date
contact-forms 1 year ago contact-forms.php 1 year ago fluent-booking.php 9 months ago index.php 1 month ago newsletters.php 1 year ago recommendation-page-post-type.php 1 year ago recommendations-trait.php 3 months ago siteleads.php 3 months ago
recommendation-page-post-type.php
124 lines
1 <?php
2 use Kubio\Core\Importer;
3
4 add_action(
5 'init',
6 function () {
7 $recommendation_page_post_type = 'kubio_recommend_page';
8 $args = array(
9 'labels' => __( 'Recommendation pages', 'kubio' ),
10 'public' => true,
11 'has_archive' => false,
12 'rewrite' => false,
13 'show_in_rest' => true,
14 'show_in_menu' => false,
15 'show_in_nav_menus' => false,
16 'exclude_from_search' => true,
17 'supports' => array( 'editor', 'custom-fields', 'slug', 'revisions' ),
18 'rest_controller_class' => 'WP_REST_Posts_Controller',
19 'map_meta_cap' => true,
20 'show_ui' => true,
21 'hierarchical' => false,
22 );
23
24 register_post_type( $recommendation_page_post_type, $args );
25
26 register_post_meta(
27 $recommendation_page_post_type,
28 'plugin_slug',
29 array(
30 'type' => 'string',
31 'single' => true,
32 'show_in_rest' => true,
33 'auth_callback' => '__return_true',
34 )
35 );
36
37 register_post_meta(
38 $recommendation_page_post_type,
39 'plugin_form_id',
40 array(
41 'type' => 'integer',
42 'single' => true,
43 'show_in_rest' => true,
44 'auth_callback' => '__return_true',
45 )
46 );
47 }
48 );
49 function kubio_import_recommendation_page_post_type_template( $override = false ) {
50 $single_template = file_get_contents( KUBIO_ROOT_DIR . '/defaults/recommendations-templates/single-kubio_recommend_page.html' );
51
52 Importer::createTemplate( 'single-kubio_recommend_page', $single_template, $override, 'kubio' );
53 }
54 function kubio_delete_recommend_page_for_plugin( $plugin_slug, $plugin_form_id ) {
55 // get kubio_recommend_page posts with the plugin_slug and plugin_form_id
56 $recommendation_page_posts = get_posts(
57 array(
58 'post_type' => 'kubio_recommend_page',
59 'posts_per_page' => -1,
60 'meta_query' => array(
61 array(
62 'key' => 'plugin_slug',
63 'value' => $plugin_slug,
64 'compare' => '=',
65 ),
66 array(
67 'key' => 'plugin_form_id',
68 'value' => $plugin_form_id,
69 'compare' => '=',
70 ),
71 ),
72 'fields' => 'ids', // Only get post IDs
73 )
74 );
75
76 foreach ( $recommendation_page_posts as $recommendation_page_post_id ) {
77 wp_delete_post( $recommendation_page_post_id, true );
78 }
79 }
80
81 add_action(
82 'delete_post',
83 /**
84 * @param int $post_id Post ID.
85 * @param WP_Post $post Post object.
86 */
87 function ( $post_id, $post ) {
88
89 $supported_post_types = array(
90 class_exists( \WPCF7_ContactForm::class ) ? \WPCF7_ContactForm::post_type : 'wpcf7_contact_form',
91
92 );
93 if ( ! in_array( $post->post_type, $supported_post_types, true ) ) {
94 return;
95 }
96
97 $plugin_slug = null;
98
99 switch ( $post->post_type ) {
100 case class_exists( \WPCF7_ContactForm::class ) ? \WPCF7_ContactForm::post_type : 'wpcf7_contact_form':
101 $plugin_slug = 'contact-form-7';
102 break;
103
104 }
105
106 kubio_delete_recommend_page_for_plugin(
107 $plugin_slug,
108 $post_id
109 );
110 },
111 10,
112 2
113 );
114
115 add_action(
116 'fluent_booking/before_delete_calendar_event',
117 function ( $calendar ) {
118 kubio_delete_recommend_page_for_plugin(
119 'fluent-booking',
120 $calendar->id
121 );
122 }
123 );
124