-
Notifications
You must be signed in to change notification settings - Fork 0
/
symlink.php
73 lines (54 loc) · 1.98 KB
/
symlink.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
<?php
/*
Plugin Name: Symlinks
Description: Create an alias -or multiple- for any post type & Disable /programs/ from url
Version: 2.0
Author: <a href="mailto:[email protected]">[email protected]</a>
*/
namespace Wiley\Symlinks;
defined( 'WILEY_SYMLINKS_DIR' ) or define( 'WILEY_SYMLINKS_DIR', plugin_dir_path( __FILE__ ) );
defined( 'WILEY_SYMLINKS_URL' ) or define( 'WILEY_SYMLINKS_URL', plugin_dir_url( __FILE__ ) );
defined( 'WILEY_SYMLINKS_FILE' ) or define( 'WILEY_SYMLINKS_FILE', plugin_basename( __FILE__ ) );
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// WP admin stuff to manage the URL data
include_once( WILEY_SYMLINKS_DIR . 'inc/sidebar.php' );
// bridge between admin data and rewrites: flush rewrites when a symlink is updated
include_once( WILEY_SYMLINKS_DIR . 'inc/flush.php' );
// actual URL rewrites
include_once( WILEY_SYMLINKS_DIR . 'inc/rewrites.php' );
// modify permalinks of "child" when on a "parent"
include_once( WILEY_SYMLINKS_DIR . 'inc/get-permalink.php' );
// show other symlinks in admin bar
include_once( WILEY_SYMLINKS_DIR . 'inc/admin-bar.php' );
// overview plugin page
include_once( WILEY_SYMLINKS_DIR . 'inc/admin-page.php' );
/**
* Legacy Affiliate Pages
*/
// rewrites + settings page
include_once( WILEY_SYMLINKS_DIR . 'inc/legacy/af-rule.php' );
include_once( WILEY_SYMLINKS_DIR . 'inc/legacy/remove-program.php' );
// affiliate helpers
include_once( WILEY_SYMLINKS_DIR . 'inc/legacy/af-class.php' );
include_once( WILEY_SYMLINKS_DIR . 'inc/legacy/af-helpers.php' );
// backend CSS
function symlinks_backend( $hook_suffix ) {
if ( $hook_suffix == 'settings_page_symlinks-wes' ) {
wp_enqueue_style(
'simlinks-css',
WILEY_SYMLINKS_DIR . 'build/index.css',
true
);
}
}
add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\\symlinks_backend' );
// WP-CLI
function symlink_is_cli_running() {
return defined('WP_CLI') && WP_CLI;
}
if (symlink_is_cli_running()) {
include_once( WILEY_SYMLINKS_DIR . 'inc/cli-commands.php' );
}