-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmultilify.php
More file actions
120 lines (108 loc) · 3.23 KB
/
Copy pathmultilify.php
File metadata and controls
120 lines (108 loc) · 3.23 KB
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
<?php
/**
* Plugin Name: Multilify
* Plugin URI: https://multilify.com
* Description: A powerful multilingual content management system for WordPress. Supports unlimited languages with custom slugs, SEO optimization, and performance caching.
* Version: 1.2.0
* Requires at least: 5.8
* Requires PHP: 7.4
* Author: Kadir Erman
* Author URI: https://kadirerman.com
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: multilify
* Domain Path: /languages
*
* @package Multilify
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Define plugin constants.
define( 'MULTILIFY_VERSION', '1.2.0' );
define( 'MULTILIFY_PLUGIN_FILE', __FILE__ );
define( 'MULTILIFY_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'MULTILIFY_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'MULTILIFY_INCLUDES_DIR', MULTILIFY_PLUGIN_DIR . 'includes/' );
define( 'MULTILIFY_ASSETS_URL', MULTILIFY_PLUGIN_URL . 'assets/' );
/**
* Load the main plugin class.
*/
require_once MULTILIFY_INCLUDES_DIR . 'class-multilify.php';
/**
* Initialize the plugin.
*/
function multilify() {
return Multilify::get_instance();
}
// Start the plugin.
multilify();
/**
* Helper function for language switcher.
*
* @param array $args {
* Optional. Display arguments.
*
* @type bool $show_flag Whether to show the flag. Default true.
* @type bool $show_name Whether to show the language name. Default true.
* }
*/
function multilify_switcher( $args = array() ) {
// Output is already escaped in get_language_switcher method.
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo multilify()->get_language_switcher( $args );
}
/**
* Activation hook.
*/
function multilify_activate() {
// Set default options if they don't exist.
if ( ! get_option( 'multilify_languages' ) ) {
$default_languages = array(
array(
'code' => 'en',
'name' => 'English',
'flag' => '🇬🇧',
),
array(
'code' => 'tr',
'name' => 'Türkçe',
'flag' => '🇹🇷',
),
);
update_option( 'multilify_languages', $default_languages );
}
if ( ! get_option( 'multilify_default_language' ) ) {
update_option( 'multilify_default_language', 'en' );
}
// Setup rewrite rules before flushing.
$multilify = multilify();
$multilify->setup_rewrite_rules();
// Flush rewrite rules on activation.
flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'multilify_activate' );
/**
* Deactivation hook.
*/
function multilify_deactivate() {
// Flush rewrite rules on deactivation.
flush_rewrite_rules();
}
register_deactivation_hook( __FILE__, 'multilify_deactivate' );
/**
* Add plugin action links (Settings, View details).
*
* @param array $links Existing plugin action links.
* @param string $file Plugin file path relative to the plugins directory.
* @return array Filtered plugin action links.
*/
function multilify_plugin_action_links( $links, $file ) {
if ( plugin_basename( __FILE__ ) === $file ) {
$settings_link = '<a href="' . admin_url( 'admin.php?page=multilify' ) . '">' . esc_html__( 'Settings', 'multilify' ) . '</a>';
array_unshift( $links, $settings_link );
}
return $links;
}
add_filter( 'plugin_action_links', 'multilify_plugin_action_links', 10, 2 );