PluginProbe ʕ •ᴥ•ʔ
Advanced 301 and 302 Redirect / 1.2.3
Advanced 301 and 302 Redirect v1.2.3
1.7.0 trunk 1.0.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.7 1.6.8 1.6.9
advanced-301-and-302-redirect / index.php
advanced-301-and-302-redirect Last commit date
images 6 years ago include 6 years ago index.php 6 years ago notices.php 6 years ago readme.txt 2 days ago
index.php
117 lines
1 <?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>
2 <?php
3 /*
4 Plugin Name: Advanced 301 and 302 Redirect
5 Plugin URI: http://www.yydevelopment.com/
6 Description: Simple plugin that will allow to redirect pages as 301 and 302 redirects in wordpress
7 Version: 1.2.3
8 Author: YYDevelopment
9 Author URI: http://www.yydevelopment.co.il/
10 */
11
12 include('include/settings.php');
13 require_once('include/functions.php');
14
15 $yydev_redirect_data_plugin_version = '1.2.3'; // plugin version
16 $yydev_redirect_data_slug_name = 'yydev_advanced_301_redirect_version'; // the name we save on the wp_options database
17
18 // ================================================
19 // Creating Database when the plugin is activated
20 // ================================================
21
22 function yydev_redirect_create_redirection_database() {
23 require_once('include/install.php');
24 }
25
26 register_activation_hook(__FILE__, 'yydev_redirect_create_redirection_database');
27
28 // ================================================
29 // update the database on plugin update
30 // ================================================
31
32 // loading the plugin version from the database
33 $db_plugin_version = get_option($yydev_redirect_data_slug_name);
34
35 // checking if the plugin version exists on the dabase
36 // and checking if the database version equal to the plugin version $yydev_redirect_data_plugin_version
37 if( empty($db_plugin_version) || ($yydev_redirect_data_plugin_version != $db_plugin_version) ) {
38
39 // update the plugin database if it's required
40 $yydev_redirect_database_update = 1;
41 require_once('include/install.php');
42
43 // update the plugin version in the database
44 update_option($yydev_redirect_data_slug_name, $yydev_redirect_data_plugin_version);
45
46 } // if( empty($db_plugin_version) || ($yydev_redirect_data_plugin_version != $db_plugin_version) ) {
47
48 // add_action('plugins_loaded', 'my_awesome_plugin_check_version');
49
50
51 // ================================================
52 // Adding menu tag inside wordpress admin panel
53 // ================================================
54
55 function yydev_redirect_wordpress_redirect_page() {
56
57 include('include/settings.php');
58
59 include('include/style.php');
60 include('include/script.php');
61
62 // Including the main page and the secondary page
63 if( isset($_GET['view']) && isset($_GET['id']) && ($_GET['view'] = 'secondary') ) {
64 include('include/secondary-page.php');
65 } else {
66 include('include/main-page.php');
67 }
68
69 }
70
71
72 function yydev_redirect_plugin_menu() {
73 include('include/settings.php');
74 add_options_page('301/302 Redirection', '301/302 Redirection', 'manage_options', 'yydev-redirection', 'yydev_redirect_wordpress_redirect_page');
75 }
76
77 add_action('admin_menu', 'yydev_redirect_plugin_menu');
78
79 // ================================================
80 // Add settings page to the plugin menu info
81 // ================================================
82
83 function yydev_redirect_add_settings_link( $actions, $plugin_file ) {
84 static $plugin;
85
86 if (!isset($plugin)) { $plugin = plugin_basename(__FILE__); }
87
88 if ($plugin == $plugin_file) {
89
90 $admin_page_url = esc_url( menu_page_url( 'yydev-redirection', false ) );
91 $settings = array('settings' => '<a href="' . $admin_page_url . '">Settings</a>');
92
93 $actions = array_merge($settings, $actions);
94
95 } // if ($plugin == $plugin_file) {
96
97 return $actions;
98 } //function yydev_redirect_add_settings_link( $actions, $plugin_file ) {
99
100 add_filter( 'plugin_action_links', 'yydev_redirect_add_settings_link', 10, 5 );
101
102 // ================================================
103 // Include the redirect functions only if the theme
104 // is loaded and not on the admin panel area
105 // ================================================
106
107 if ( ! is_admin() ) {
108 require_once('include/redirect-page.php');
109 } // if ( ! is_admin() ) {
110
111 // ================================================
112 // including admin notices flie
113 // ================================================
114
115 if( is_admin() ) {
116 include_once('notices.php');
117 } // if( is_admin() ) {