This repository has been archived by the owner on Oct 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pods-stream.php
172 lines (135 loc) · 4.56 KB
/
pods-stream.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
/*
Plugin Name: Pods Stream Connector
Plugin URI: http://pods.io/
Description: Integrates with the WordPress Stream plugin to track changes to Pods and content
Version: 3.0
Author: Pods Framework Team, Nikhil Vimal
Author URI: http://pods.io/about/
Text Domain: pods-stream
Domain Path: /languages/
Copyright 2015-2017 Pods Foundation, Inc (email : [email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* The URL for this plugin.
*
* @since 0.1.0
*/
define( 'PODS_STREAM_DIR', plugin_dir_path( __FILE__ ) );
/**
* Init Stream integration
*
* @since 0.1.0
*/
function pods_stream_init() {
if ( defined('PODS_VERSION') ) {
// Check if the Stream Connector Class exists
if ( class_exists( '\WP_Stream\Connector' ) ) {
if ( ! class_exists( 'WP_Stream_Connector_Pods_Base' ) ) {
include_once PODS_STREAM_DIR . 'includes/WP_Stream_Connector_Pods_Base.php';
}
if ( ! class_exists( 'WP_Stream_Connector_Pods' ) ) {
include_once PODS_STREAM_DIR . 'includes/WP_Stream_Connector_Pods.php';
}
if ( ! class_exists( 'WP_Stream_Connector_Pods_Content' ) ) {
include_once PODS_STREAM_DIR . 'includes/WP_Stream_Connector_Pods_Content.php';
}
do_action( 'pods_stream_init' );
} else {
//use the global pagenow so we can tell if we are on plugins admin page
global $pagenow;
if ( $pagenow == 'plugins.php' ) {
?>
<div class="error">
<p><?php _e( 'Pods Stream Connector requires the WordPress Stream plugin be activated to work.', 'pods-stream' ); ?></p>
</div>
<?php
}
}
}
}
add_action( 'init', 'pods_stream_init', 8 );
/**
* Load plugin textdomain.
*
* @since 0.1.0
*/
function pods_stream_load_textdomain() {
load_plugin_textdomain( 'pods-stream', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
add_action( 'plugins_loaded', 'pods_stream_load_textdomain' );
/**
* Check if the right version of Pods is installed
*
* @since 0.1.0
*/
function pods_stream_admin_notice_pods_min_version_fail() {
if ( defined( 'PODS_VERSION' ) ) {
//set minimum supported version of Pods.
$minimum_version = '2.5.1.1';
//check if Pods version is greater than or equal to minimum supported version for this plugin
if ( version_compare( $minimum_version, PODS_VERSION ) >= 0 ) {
//create $page variable to check if we are on pods admin page
$page = pods_v( 'page', 'get', false, true );
//check if we are on Pods Admin page
if ( $page === 'pods' ) {
?>
<div class="error">
<p><?php _e( 'Pods Stream Connector, requires Pods version ' . $minimum_version . ' or later. Current version of Pods is ' . PODS_VERSION, 'pods-stream' ); ?></p>
</div>
<?php
} //endif on the right page
} //endif version compare
} //endif Pods is not active
}
add_action( 'admin_notices', 'pods_stream_admin_notice_pods_min_version_fail' );
/**
* Throw admin nag if Pods isn't activated.
*
* Will only show on the plugins page.
*
* @since 0.1.0
*/
function pods_stream_admin_notice_pods_not_active() {
if ( ! defined( 'PODS_VERSION' ) ) {
//Use the global pagenow so we can tell if we are on plugins admin page
global $pagenow;
if ( $pagenow == 'plugins.php' ) {
?>
<div class="error">
<p><?php _e( 'You have activated Pods Stream Connector, but not the core Pods plugin.', 'pods-stream' ); ?></p>
</div>
<?php
} //endif on the right page
} //endif Pods is not active
}
add_action( 'admin_notices', 'pods_stream_admin_notice_pods_not_active' );
/**
* Add Pods internal post types to be excluded from Stream Posts Connector
*
* @param array $post_types Post types to exclude
*
* @return array
*
* @since 0.1.0
*/
function pods_stream_exclude_internal( $post_types ) {
$post_types[] = '_pods_pod';
$post_types[] = '_pods_field';
$post_types[] = '_pods_group';
$post_types[] = '_pods_page';
$post_types[] = '_pods_template';
return $post_types;
}
add_filter( 'wp_stream_posts_exclude_post_types', 'pods_stream_exclude_internal' );