-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsejwp_urls.php
112 lines (89 loc) · 2.56 KB
/
sejwp_urls.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
<?php
/*
Plugin Name: Register url
Plugin URI: http://www.ondrej-sejvl.cz
Description:
Version: 1.0
Author: Ondřej Šejvl
Author URI: http://www.ondrej-sejvl.cz
License: GPL2
*/
/* Copyright 2015 Ondrej Sejvl (email : info@ondrej-sejvl.cz)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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
*/
namespace sejvlond\wordpress\plugins\urls;
/**
* start sessions
*/
function register_session ( ) {
error_reporting(0);
if( ! session_id() ) {
//session_save_path( dirname ( __FILE__ ) . "/sessions");
session_start();
}
}
add_action ( 'init', __NAMESPACE__.'\\register_session' );
// ob
function add_ob_start(){
ob_start();
}
function flush_ob_end(){
ob_end_flush();
}
add_action('init', __NAMESPACE__.'\\add_ob_start');
add_action('wp_footer', __NAMESPACE__.'\\flush_ob_end');
/**
* Load all php files from dir recoursively
*
* @param string $path
*/
function loadDir ( $path ) {
foreach ( scandir( $path ) as $file ) {
if ( $file == '.' || $file == '..' )
continue;
if ( is_dir ( $path.'/'.$file ) ) {
loadDir ( $path.'/'.$file );
}
if ( substr ( $file, -4 ) == '.php' ) {
include $path.'/'.$file;
}
}
}
/**
* Auto load all files from app folder
*/
function autoLoad ( ) {
loadDir ( __DIR__ . "/app" );
}
/**
* APP DIR OF PLUGIN
*/
define ( APP_DIR, __DIR__.'/app' );
/**
* TEMPLATE DIR OF PLUGIN
*/
define ( TEMPLATES_DIR, APP_DIR.'/templates' );
/**
* ABSOLUTE URL OF PLUGIN
*/
define ( PLUGIN_URL, plugins_url( '' , __FILE__ ) );
/**
* Redirect to homepage of plugin
*/
function redirectHome ( ) {
wp_redirect( menu_page_url ( 'sejwp_urls_list', false ) );
exit;
}
// ************************************************************************************
autoLoad();
load_plugin_textdomain('sejwp_urls', false, basename( dirname( __FILE__ ) ) . '/languages' );
register_activation_hook( __FILE__, __NAMESPACE__ . '\\install\\install' );