forked from dshanske/indieweb-post-kinds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
indieweb-post-kinds.php
executable file
·129 lines (110 loc) · 4.28 KB
/
indieweb-post-kinds.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
<?php
/**
* Post Kinds
*
* @link http://indieweb.org/Post_Kinds_Plugin
* @package Post Kinds
* Plugin Name: Post Kinds
* Plugin URI: https://wordpress.org/plugins/indieweb-post-kinds/
* Description: Ever want to reply to someone else's post with a post on your own site? Or to "like" someone else's post, but with your own site?
* Version: 2.5.2
* Author: David Shanske
* Author URI: https://david.shanske.com
* Text Domain: indieweb-post-kinds
* Domain Path: /languages
*/
if ( ! defined( 'MULTIKIND' ) ) {
define( 'MULTIKIND', false );
}
add_action( 'plugins_loaded', array( 'Post_Kinds_Plugin', 'plugins_loaded' ) );
add_action( 'init', array( 'Post_Kinds_Plugin', 'init' ) );
class Post_Kinds_Plugin {
public static $version = '2.5.2';
public static function init() {
// Add Kind Taxonomy.
require_once plugin_dir_path( __FILE__ ) . 'includes/class-kind-taxonomy.php';
Kind_Taxonomy::init();
Kind_Taxonomy::register();
}
public static function plugins_loaded() {
load_plugin_textdomain( 'indieweb-post-kinds', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
// On Activation, add terms.
register_activation_hook( __FILE__, array( 'Kind_Taxonomy', 'activate_kinds' ) );
// Add Kind Global Functions.
require_once plugin_dir_path( __FILE__ ) . '/includes/kind-functions.php';
// Plugin Specific Kind Customizations
require_once plugin_dir_path( __FILE__ ) . '/includes/class-kind-plugins.php';
add_action( 'init' , array( 'Kind_Plugins', 'init' ) );
// Config Settings.
require_once plugin_dir_path( __FILE__ ) . 'includes/class-kind-config.php';
add_action( 'init' , array( 'Kind_Config', 'init' ) );
// Add a Settings Link to the Plugins Page.
$plugin = plugin_basename( __FILE__ );
add_filter( 'plugin_action_links_$plugin', array( 'Post_Kinds_Plugin', 'settings_link' ) );
// Add Kind Post UI Configuration
require_once plugin_dir_path( __FILE__ ) . 'includes/class-kind-tabmeta.php';
add_action( 'init' , array( 'Kind_Tabmeta', 'init' ) );
Kind_Tabmeta::$version = self::$version;
// Add Kind Display Functions.
require_once plugin_dir_path( __FILE__ ) . 'includes/class-kind-view.php';
add_action( 'init' , array( 'Kind_View', 'init' ) );
// Add Kind Meta Storage and Retrieval Functions.
require_once plugin_dir_path( __FILE__ ) . 'includes/class-kind-meta.php';
// Add an MF2 Parser
if ( version_compare( PHP_VERSION, '5.3', '>' ) ) {
if ( ! class_exists( 'Mf2\Parser' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'includes/Mf2/Parser.php';
}
if ( ! function_exists( 'Mf2\xpcs' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'includes/Mf2/functions.php';
}
if ( ! class_exists( 'Mf2\Shim' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'includes/Mf2/Twitter.php';
}
require_once plugin_dir_path( __FILE__ ) . 'includes/class-parse-mf2.php';
}
// Add Link Preview Parsing
require_once plugin_dir_path( __FILE__ ) . 'includes/class-parse-this.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/class-link-preview.php';
add_action( 'init' , array( 'Link_Preview', 'init' ) );
// Load stylesheets.
add_action( 'wp_enqueue_scripts', array( 'Post_Kinds_Plugin', 'style_load' ) );
add_action( 'admin_enqueue_scripts', array( 'Post_Kinds_Plugin', 'admin_style_load' ) );
}
/**
* Adds link to Plugin Page for Options Page.
*
* @access public
* @param array $links Array of Existing Links.
* @return array Modified Links.
*/
public static function settings_link( $links ) {
$settings_link = '<a href="options-general.php?page=kind_options">Settings</a>';
array_unshift( $links, $settings_link );
return $links;
}
/**
* Loads the Stylesheet for the Plugin.
*/
public static function style_load() {
wp_enqueue_style( 'kind', plugin_dir_url( __FILE__ ) . 'css/kind.min.css', array(), self::$version );
}
/**
* Loads the Admin Stylesheet for the Plugin.
*/
public static function admin_style_load() {
wp_enqueue_style( 'kind-admin', plugin_dir_url( __FILE__ ) . 'css/kind.admin.min.css', array(), self::$version );
}
}
if ( ! function_exists( 'ifset' ) ) {
/**
* If set, return otherwise false.
*
* @param type $var Check if set.
* @return $var|false Return either $var or false.
*/
function ifset(&$var) {
return isset( $var ) ? $var : false;
}
}
?>