| @@ -51,23 +51,23 @@ | ||
| 51 | 51 | * wpLingua's hidden option pages. |
| 52 | 52 | */ |
| 53 | 53 | function wplng_is_wplingua_settings_page() { |
| 54 | 54 | |
| 55 | - if ( empty( $_GET['page'] ) ) { | |
| 56 | - return false; | |
| 57 | - } | |
| 55 | + if ( empty( $_GET['page'] ) ) { | |
| 56 | + return false; | |
| 57 | + } | |
| 58 | 58 | |
| 59 | - return in_array( | |
| 60 | - sanitize_key( $_GET['page'] ), | |
| 61 | - array( | |
| 62 | - 'wplingua-settings', | |
| 63 | - 'wplingua-switcher', | |
| 64 | - 'wplingua-exclusions', | |
| 65 | - 'wplingua-dictionary', | |
| 66 | - 'wplingua-link-media', | |
| 67 | - ), | |
| 68 | - true | |
| 69 | - ); | |
| 59 | + return in_array( | |
| 60 | + sanitize_key( $_GET['page'] ), | |
| 61 | + array( | |
| 62 | + 'wplingua-settings', | |
| 63 | + 'wplingua-switcher', | |
| 64 | + 'wplingua-exclusions', | |
| 65 | + 'wplingua-dictionary', | |
| 66 | + 'wplingua-link-media', | |
| 67 | + ), | |
| 68 | + true | |
| 69 | + ); | |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | |
| 73 | 73 | /** |
| @@ -154,104 +154,101 @@ | ||
| 154 | 154 | * Create wpLingua admin menu. |
| 155 | 155 | */ |
| 156 | 156 | function wplng_create_menu() { |
| 157 | 157 | |
| 158 | - /* | |
| 159 | - * Main wpLingua menu | |
| 160 | - */ | |
| 161 | - add_menu_page( | |
| 162 | - __( 'wpLingua: Settings', 'wplingua' ), | |
| 163 | - __( 'wpLingua', 'wplingua' ), | |
| 164 | - 'edit_posts', | |
| 165 | - 'wplingua-settings', | |
| 166 | - '', | |
| 167 | - 'dashicons-translation', | |
| 168 | - 31 | |
| 169 | - ); | |
| 158 | + /* | |
| 159 | + * Main wpLingua menu | |
| 160 | + */ | |
| 161 | + add_menu_page( | |
| 162 | + __( 'wpLingua: Settings', 'wplingua' ), | |
| 163 | + __( 'wpLingua', 'wplingua' ), | |
| 164 | + 'edit_posts', | |
| 165 | + 'wplingua-settings', | |
| 166 | + '', | |
| 167 | + 'dashicons-translation', | |
| 168 | + 31 | |
| 169 | + ); | |
| 170 | 170 | |
| 171 | + /* | |
| 172 | + * Settings | |
| 173 | + * | |
| 174 | + * This is the visible entry used as the parent | |
| 175 | + * for all wpLingua option pages. | |
| 176 | + */ | |
| 177 | + add_submenu_page( | |
| 178 | + 'wplingua-settings', | |
| 179 | + __( 'wpLingua: Settings', 'wplingua' ), | |
| 180 | + __( 'Settings', 'wplingua' ), | |
| 181 | + 'edit_posts', | |
| 182 | + 'wplingua-settings', | |
| 183 | + 'wplng_option_page_settings' | |
| 184 | + ); | |
| 171 | 185 | |
| 172 | - /* | |
| 173 | - * Settings | |
| 174 | - * | |
| 175 | - * This is the visible entry used as the parent | |
| 176 | - * for all wpLingua option pages. | |
| 177 | - */ | |
| 178 | - add_submenu_page( | |
| 179 | - 'wplingua-settings', | |
| 180 | - __( 'wpLingua: Settings', 'wplingua' ), | |
| 181 | - __( 'Settings', 'wplingua' ), | |
| 182 | - 'edit_posts', | |
| 183 | - 'wplingua-settings', | |
| 184 | - 'wplng_option_page_settings' | |
| 185 | - ); | |
| 186 | + /* | |
| 187 | + * Hidden option pages | |
| 188 | + * | |
| 189 | + * These pages remain registered as children of | |
| 190 | + * wplingua-settings, but their menu entries are | |
| 191 | + * hidden later with CSS. | |
| 192 | + */ | |
| 186 | 193 | |
| 194 | + add_submenu_page( | |
| 195 | + 'wplingua-settings', | |
| 196 | + __( 'wpLingua: Switcher', 'wplingua' ), | |
| 197 | + __( 'Switcher', 'wplingua' ), | |
| 198 | + 'edit_posts', | |
| 199 | + 'wplingua-switcher', | |
| 200 | + 'wplng_option_page_switcher' | |
| 201 | + ); | |
| 187 | 202 | |
| 188 | - /* | |
| 189 | - * Hidden option pages | |
| 190 | - * | |
| 191 | - * These pages remain registered as children of | |
| 192 | - * wplingua-settings, but their menu entries are | |
| 193 | - * hidden later with CSS. | |
| 194 | - */ | |
| 203 | + add_submenu_page( | |
| 204 | + 'wplingua-settings', | |
| 205 | + __( 'wpLingua: Exclusion', 'wplingua' ), | |
| 206 | + __( 'Exclusion', 'wplingua' ), | |
| 207 | + 'edit_posts', | |
| 208 | + 'wplingua-exclusions', | |
| 209 | + 'wplng_option_page_exclusions' | |
| 210 | + ); | |
| 195 | 211 | |
| 196 | - add_submenu_page( | |
| 197 | - 'wplingua-settings', | |
| 198 | - __( 'wpLingua: Switcher', 'wplingua' ), | |
| 199 | - __( 'Switcher', 'wplingua' ), | |
| 200 | - 'edit_posts', | |
| 201 | - 'wplingua-switcher', | |
| 202 | - 'wplng_option_page_switcher' | |
| 203 | - ); | |
| 212 | + add_submenu_page( | |
| 213 | + 'wplingua-settings', | |
| 214 | + __( 'wpLingua: Dictionary', 'wplingua' ), | |
| 215 | + __( 'Dictionary', 'wplingua' ), | |
| 216 | + 'edit_posts', | |
| 217 | + 'wplingua-dictionary', | |
| 218 | + 'wplng_option_page_dictionary' | |
| 219 | + ); | |
| 204 | 220 | |
| 205 | - add_submenu_page( | |
| 206 | - 'wplingua-settings', | |
| 207 | - __( 'wpLingua: Exclusion', 'wplingua' ), | |
| 208 | - __( 'Exclusion', 'wplingua' ), | |
| 209 | - 'edit_posts', | |
| 210 | - 'wplingua-exclusions', | |
| 211 | - 'wplng_option_page_exclusions' | |
| 212 | - ); | |
| 221 | + add_submenu_page( | |
| 222 | + 'wplingua-settings', | |
| 223 | + __( 'wplingua: Links & Medias', 'wplingua' ), | |
| 224 | + __( 'Links & Medias', 'wplingua' ), | |
| 225 | + 'edit_posts', | |
| 226 | + 'wplingua-link-media', | |
| 227 | + 'wplng_option_page_link_media' | |
| 228 | + ); | |
| 213 | 229 | |
| 214 | - add_submenu_page( | |
| 215 | - 'wplingua-settings', | |
| 216 | - __( 'wpLingua: Dictionary', 'wplingua' ), | |
| 217 | - __( 'Dictionary', 'wplingua' ), | |
| 218 | - 'edit_posts', | |
| 219 | - 'wplingua-dictionary', | |
| 220 | - 'wplng_option_page_dictionary' | |
| 221 | - ); | |
| 230 | + /* | |
| 231 | + * Visible custom post type pages | |
| 232 | + */ | |
| 222 | 233 | |
| 223 | - add_submenu_page( | |
| 224 | - 'wplingua-settings', | |
| 225 | - __( 'wplingua: Links & Medias', 'wplingua' ), | |
| 226 | - __( 'Links & Medias', 'wplingua' ), | |
| 227 | - 'edit_posts', | |
| 228 | - 'wplingua-link-media', | |
| 229 | - 'wplng_option_page_link_media' | |
| 230 | - ); | |
| 234 | + add_submenu_page( | |
| 235 | + 'wplingua-settings', | |
| 236 | + __( 'wpLingua: Website slugs', 'wplingua' ), | |
| 237 | + __( 'Website slugs', 'wplingua' ), | |
| 238 | + 'edit_posts', | |
| 239 | + 'edit.php?post_type=wplng_slug', | |
| 240 | + false | |
| 241 | + ); | |
| 231 | 242 | |
| 232 | - | |
| 233 | - /* | |
| 234 | - * Visible custom post type pages | |
| 235 | - */ | |
| 236 | - | |
| 237 | - add_submenu_page( | |
| 238 | - 'wplingua-settings', | |
| 239 | - __( 'wpLingua: Website slugs', 'wplingua' ), | |
| 240 | - __( 'Website slugs', 'wplingua' ), | |
| 241 | - 'edit_posts', | |
| 242 | - 'edit.php?post_type=wplng_slug', | |
| 243 | - false | |
| 244 | - ); | |
| 245 | - | |
| 246 | - add_submenu_page( | |
| 247 | - 'wplingua-settings', | |
| 248 | - __( 'wpLingua: Translations', 'wplingua' ), | |
| 249 | - __( 'All translations', 'wplingua' ), | |
| 250 | - 'edit_posts', | |
| 251 | - 'edit.php?post_type=wplng_translation', | |
| 252 | - false | |
| 253 | - ); | |
| 243 | + add_submenu_page( | |
| 244 | + 'wplingua-settings', | |
| 245 | + __( 'wpLingua: Translations', 'wplingua' ), | |
| 246 | + __( 'All translations', 'wplingua' ), | |
| 247 | + 'edit_posts', | |
| 248 | + 'edit.php?post_type=wplng_translation', | |
| 249 | + false | |
| 250 | + ); | |
| 254 | 251 | } |
| 255 | 252 | |
| 256 | 253 | |
| 257 | 254 | /** |
| @@ -263,13 +260,13 @@ | ||
| 263 | 260 | * @return string The parent menu file. |
| 264 | 261 | */ |
| 265 | 262 | function wplng_option_page_parent_file( $parent_file ) { |
| 266 | 263 | |
| 267 | - if ( wplng_is_wplingua_settings_page() ) { | |
| 268 | - return 'wplingua-settings'; | |
| 269 | - } | |
| 264 | + if ( wplng_is_wplingua_settings_page() ) { | |
| 265 | + return 'wplingua-settings'; | |
| 266 | + } | |
| 270 | 267 | |
| 271 | - return $parent_file; | |
| 268 | + return $parent_file; | |
| 272 | 269 | } |
| 273 | 270 | |
| 274 | 271 | |
| 275 | 272 | /** |
| @@ -281,13 +278,13 @@ | ||
| 281 | 278 | * @return string The submenu file. |
| 282 | 279 | */ |
| 283 | 280 | function wplng_option_page_submenu_file( $submenu_file ) { |
| 284 | 281 | |
| 285 | - if ( wplng_is_wplingua_settings_page() ) { | |
| 286 | - return 'wplingua-settings'; | |
| 287 | - } | |
| 282 | + if ( wplng_is_wplingua_settings_page() ) { | |
| 283 | + return 'wplingua-settings'; | |
| 284 | + } | |
| 288 | 285 | |
| 289 | - return $submenu_file; | |
| 286 | + return $submenu_file; | |
| 290 | 287 | } |
| 291 | 288 | |
| 292 | 289 | |
| 293 | 290 | /** |
| @@ -298,9 +295,9 @@ | ||
| 298 | 295 | * and remain correctly associated with the wpLingua menu. |
| 299 | 296 | */ |
| 300 | 297 | function wplng_option_page_hide_submenu() { |
| 301 | 298 | |
| 302 | - $css = '<style>'; | |
| 299 | + $css = '<style>'; | |
| 303 | 300 | $css .= '#adminmenu .wp-submenu a[href*="page=wplingua-switcher"], '; |
| 304 | 301 | $css .= '#adminmenu .wp-submenu a[href*="page=wplingua-exclusions"], '; |
| 305 | 302 | $css .= '#adminmenu .wp-submenu a[href*="page=wplingua-dictionary"], '; |
| 306 | 303 | $css .= '#adminmenu .wp-submenu a[href*="page=wplingua-link-media"] {'; |
| @@ -821,8 +818,60 @@ | ||
| 821 | 818 | $html .= 'href="' . esc_url( $url_permalinks ) . '" '; |
| 822 | 819 | $html .= 'class="button button-primary" '; |
| 823 | 820 | $html .= 'style="margin-bottom: 10px;">'; |
| 824 | 821 | $html .= esc_html__( 'Manage permalink settings', 'wplingua' ); |
| 822 | + $html .= '</a>'; | |
| 823 | + $html .= '</div>'; // End .notice | |
| 824 | + | |
| 825 | + echo $html; | |
| 826 | +} | |
| 827 | + | |
| 828 | + | |
| 829 | +/** | |
| 830 | + * Display a notice for obtaining the PRO version of the plugin | |
| 831 | + * - Only for non free user | |
| 832 | + * - Only on wpLingua option's pages | |
| 833 | + * - Only if PRO plugin not already activated | |
| 834 | + * | |
| 835 | + * @return void|string Outputs the admin notice if applicable, or returns void if no notice is required. | |
| 836 | + */ | |
| 837 | +function wplng_admin_notice_get_pro_version() { | |
| 838 | + | |
| 839 | + if ( is_plugin_active( 'wplingua-pro/wplingua-pro.php' ) ) { | |
| 840 | + return; | |
| 841 | + } | |
| 842 | + | |
| 843 | + $data = wplng_get_api_data(); | |
| 844 | + | |
| 845 | + if ( empty( $data['status'] ) | |
| 846 | + || $data['status'] === 'FREE' | |
| 847 | + ) { | |
| 848 | + return; | |
| 849 | + } | |
| 850 | + | |
| 851 | + $html = '<div'; | |
| 852 | + $html .= ' class="wplng-notice notice notice-warning is-dismissible"'; | |
| 853 | + $html .= ' style="text-align: center;"'; | |
| 854 | + $html .= '>'; | |
| 855 | + $html .= '<p style="font-weight: 600;">'; | |
| 856 | + $html .= '<span class="dashicons dashicons-translation"></span> '; | |
| 857 | + $html .= esc_html__( 'wpLingua - Unlock PRO Features', 'wplingua' ); | |
| 858 | + $html .= '</p>'; | |
| 859 | + $html .= '<hr>'; | |
| 860 | + $html .= '<p>'; | |
| 861 | + $html .= esc_html__( 'Extend wpLingua with additional features and advanced translation capabilities.', 'wplingua' ); | |
| 862 | + $html .= '</p>'; | |
| 863 | + $html .= '<p>'; | |
| 864 | + $html .= esc_html__( 'Download and install wpLingua PRO to access the features included with your wpLingua plan.', 'wplingua' ); | |
| 865 | + $html .= '</p>'; | |
| 866 | + $html .= '<br>'; | |
| 867 | + $html .= '<a'; | |
| 868 | + $html .= ' href="https://wplingua.com/download/#pro"'; | |
| 869 | + $html .= ' target="_blank"'; | |
| 870 | + $html .= ' rel="noopener noreferrer"'; | |
| 871 | + $html .= ' class="button button-primary"'; | |
| 872 | + $html .= '>'; | |
| 873 | + $html .= esc_html__( 'wpLingua.com : Download PRO plugin', 'wplingua' ); | |
| 825 | 874 | $html .= '</a>'; |
| 826 | 875 | $html .= '</div>'; // End .notice |
| 827 | 876 | |
| 828 | 877 | echo $html; |