-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-simple-feedback.php
executable file
·109 lines (94 loc) · 2.47 KB
/
wp-simple-feedback.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
<?php
/**
* Plugin Name: WP Simple Feedback
* Plugin URI: http://feedback.lindewitz.de
* Description: This plugin provides a simple feedback possibility for the users
* Version: 0.1
* Author: Inpsyde GmbH
* Author URI: http://inpsyde.com
* Licence: GPLv3
* Text Domain: wp-simple-feedback
* Domain Path: /language
*/
if ( ! class_exists( 'WP_Simple_Feedback' ) ) {
if ( function_exists( 'add_filter' ) )
add_filter( 'plugins_loaded' , array( 'WP_Simple_Feedback', 'get_instance' ) );
class WP_Simple_Feedback {
/**
* Instance holder
*
* @var NULL | __CLASS__
*/
private static $instance = NULL;
/**
* Method for ensuring that only one instance of this object is used
*
* @return __CLASS__
*/
public static function get_instance() {
if ( ! self::$instance )
self::$instance = new self;
return self::$instance;
}
/**
* Setting up some data, initialize localization and load
* the features
*
* @return void
*/
public function __construct () {
// Translation
load_plugin_textdomain( 'wp-simple-feedback', FALSE, dirname( plugin_basename( __FILE__ ) ) . '/language' );
// Load the features
$this->load_features();
}
/**
* Returns array of features, also
* Scans the plugins subfolder "/features"
*
* @return void
*/
protected function load_features() {
// load all files with the pattern class-*.php from the directory inc
foreach ( glob( dirname( __FILE__ ) . '/inc/class-*.php' ) as $class )
require_once $class;
}
}
if ( ! function_exists( 'p' ) ) {
/**
* This helper function outputs a given string,
* object or array
*
* @param mixed $output
* @return void
*/
function p( $output ) {
print '<br /><br /><br /><pre>';
print_r( $output );
print '</pre>';
}
}
if ( ! function_exists( 'array_insert' ) ) {
/**
* This little helper function inserts an array to an array
* on a specific position
*
* @param array $array
* @param string $key
* @param array $insert
* @param boolean $before adds the array before the key
* @return array
*/
function array_insert( $array, $key, $insert, $before = FALSE ) {
$index = array_search( $key, array_keys( $array ) );
if ( $index === FALSE ){
$index = count( $array );
} else {
if ( ! $before )
$index++;
}
$end = array_splice( $array, $index );
return array_merge( $array, $insert, $end );
}
}
}