admin
1 year ago
plugins
1 year ago
views
1 year ago
widget
1 year ago
fixes-archive.php
1 year ago
fixes-archives.php
1 year ago
fixes-calendar.php
1 year ago
fixes-dates.php
1 year ago
fixes-misc.php
1 year ago
fixes-permalinks.php
1 year ago
general.php
1 year ago
install.php
1 year ago
parsidate.php
1 year ago
settings.php
1 year ago
tools.php
1 year ago
tools.php
86 lines
| 1 | <?php |
| 2 | |
| 3 | defined( 'ABSPATH' ) or exit( 'No direct script access allowed' ); |
| 4 | |
| 5 | /** |
| 6 | * WP-Parsidate Tools |
| 7 | * |
| 8 | * @author HamidReza Yazdani |
| 9 | * @sicne 5.1.0 |
| 10 | */ |
| 11 | |
| 12 | if ( wpp_is_active( 'date_in_admin_bar' ) ) { |
| 13 | |
| 14 | if ( ! function_exists( 'wpp_add_date_to_admin_bar' ) ) { |
| 15 | /** |
| 16 | * Add Jalali date to WordPress admin bar |
| 17 | * |
| 18 | * @param $wp_admin_bar |
| 19 | * |
| 20 | * @return void |
| 21 | */ |
| 22 | function wpp_add_date_to_admin_bar( $wp_admin_bar ) { |
| 23 | $current_date = parsidate( 'l Y/m/d', date( 'Y-m-d' ) ); |
| 24 | |
| 25 | $args = array( |
| 26 | 'id' => 'wpp_current_date', |
| 27 | 'title' => esc_html__( 'Today: ', 'wp-parsidate' ) . $current_date, |
| 28 | 'meta' => array( 'class' => 'wpp-admin-bar-date' ), |
| 29 | ); |
| 30 | |
| 31 | $wp_admin_bar->add_node( $args ); |
| 32 | } |
| 33 | |
| 34 | add_action( 'admin_bar_menu', 'wpp_add_date_to_admin_bar', PHP_INT_MAX ); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Style Wp-Parsidate admin bar date |
| 39 | */ |
| 40 | if ( ! function_exists( 'wpp_admin_bar_date_style' ) ) { |
| 41 | function wpp_admin_bar_date_style( $wp_admin_bar ) { |
| 42 | echo '<style> |
| 43 | .wpp-admin-bar-date { |
| 44 | color: #fff; |
| 45 | background-color: var(--e-context-primary-color) !important; |
| 46 | border-radius: 5px 5px 0 0 !important; |
| 47 | unicode-bidi: embed !important; |
| 48 | } |
| 49 | </style>'; |
| 50 | } |
| 51 | |
| 52 | add_action( 'admin_head', 'wpp_admin_bar_date_style' ); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | if ( wpp_is_active( 'disable_copy' ) ) { |
| 57 | if ( ! function_exists( 'wpp_disable_copy' ) ) { |
| 58 | function wpp_disable_copy() { |
| 59 | echo '<script> |
| 60 | document.addEventListener("DOMContentLoaded", (event) => { |
| 61 | document.body.onselectstart = () => false; |
| 62 | document.body.oncopy = (e) => { |
| 63 | e.preventDefault(); |
| 64 | return false; |
| 65 | }; |
| 66 | }); |
| 67 | </script>'; |
| 68 | } |
| 69 | |
| 70 | add_action( 'wp_footer', 'wpp_disable_copy' ); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | if ( wpp_is_active( 'disable_right_click' ) ) { |
| 75 | if ( ! function_exists( 'wpp_disable_right_click' ) ) { |
| 76 | function wpp_disable_right_click() { |
| 77 | echo '<script> |
| 78 | document.addEventListener("contextmenu", function(e) { |
| 79 | e.preventDefault(); |
| 80 | }); |
| 81 | </script>'; |
| 82 | } |
| 83 | |
| 84 | add_action( 'wp_footer', 'wpp_disable_right_click' ); |
| 85 | } |
| 86 | } |