PNG %k25u25%fgd5n!
<?php
/**
* File: Ecre_Menu.php
*
* The Ecre_Menu class defines the admin Ecre_Menu for the ECRE plugin,
* including settings and sections, with proper sanitation and rendering.
*
* @package ECRE\Admin
* @since 1.0.0
*/
namespace ECRE\Admin;
if ( ! class_exists( 'Ecre_Menu' ) ) {
/**
* Ecre_Menu
*
* Admin Ecre_Menu class for ECRE plugin.
*
* @since 1.0.0
*/
class Ecre_Menu {
/**
* Indicates whether the user has a professional (pro) account.
*
* @var bool
*/
public $is_pro = false;
/**
* Indicates whether WooCommerce is active.
*
* @var bool
*/
public $is_woocommerce_activate = false;
/**
* Ecre_Menu constructor.
*
* Initializes the Ecre_Menu instance and registers admin menu actions.
*
* @param bool $is_pro Whether the user has a pro account.
* @param bool $is_woocommerce_activate Whether WooCommerce is activated.
*/
public function __construct( $is_pro, $is_woocommerce_activate ) {
add_action( 'admin_menu', array( $this, 'ecre_add_two_sided_referral_menu' ) );
$this->is_pro = $is_pro;
$this->is_woocommerce_activate = $is_woocommerce_activate;
if ( $is_woocommerce_activate ) {
add_filter( 'submenu_file', array( $this, 'highlight_submenu_item' ) );
}
}
/**
* Add TEcho Rewards Ecre_Menu to WooCommerce marketing section.
*/
public function ecre_add_two_sided_referral_menu() {
add_menu_page(
__( 'EchoRewards', 'echo-rewards' ),
__( 'EchoRewards', 'echo-rewards' ),
'manage_options',
'echo-rewards',
array( $this, 'ecre_page_content' ),
// phpcs:ignore
'data:image/svg+xml;base64,' . base64_encode( '<svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.766 14.3264C26.2725 14.2497 32.0638 16.7248 35.1766 21.8086C35.6848 15.8687 39.7558 11.0611 44.7141 8.66313C49.0166 6.58243 53.9158 6.3757 57.6988 8.48845C59.7651 9.6428 60.6949 11.0633 61.0279 12.4071C61.4148 13.969 61.0016 15.7523 59.6839 17.4877L63.3982 16.6094C67.3155 15.683 71.2478 18.1131 72.1737 22.0324L72.5463 23.6096C73.4721 27.5293 71.0434 31.4635 67.1261 32.3898L47.7011 36.9838L44.3183 22.6628L42.8586 23.008L46.2414 37.3288L32.2293 40.6424L28.8463 26.3217L27.3866 26.6669L30.7696 40.9878L11.3449 45.5814C7.42731 46.5078 3.49529 44.0777 2.56943 40.158L2.19686 38.5811C1.271 34.6614 3.69976 30.7273 7.61702 29.8006L11.3287 28.9228C9.37405 27.9613 8.20687 26.552 7.85401 24.9817C7.55019 23.6314 7.74602 21.9444 9.07721 19.9869C11.5142 16.4028 15.9877 14.3931 20.766 14.3264ZM20.8481 20.2293C24.1976 20.1828 27.7812 21.5219 29.837 24.4407C25.4738 24.7998 18.5133 25.1211 14.6248 23.8969C14.5543 23.8747 14.4848 23.8534 14.4166 23.8325L14.4165 23.8325L14.4165 23.8325C14.1788 23.7597 13.957 23.6919 13.7673 23.6087C13.821 23.5122 13.884 23.4124 13.9552 23.308C15.3721 21.2244 18.0705 20.2682 20.8481 20.2293ZM54.823 13.6432C54.9335 13.7048 55.0346 13.766 55.1257 13.8283C54.9939 13.9867 54.8267 14.1461 54.6474 14.3172C54.595 14.3671 54.5417 14.418 54.4878 14.4702C51.5587 17.3061 45.1911 20.1371 41.1284 21.7704C41.6604 18.24 44.2656 15.4372 47.2822 13.9782C49.7829 12.7687 52.6239 12.415 54.823 13.6432ZM83.5079 53.4153L87.5512 52.0762L88.8899 48.0308C89.0854 47.4397 89.6373 47.041 90.2593 47.041C90.8813 47.041 91.4332 47.4397 91.6286 48.0308L92.9674 52.0762L97.0106 53.4153C97.601 53.6109 97.9999 54.1634 97.9999 54.7857C97.9999 55.4081 97.601 55.9603 97.0106 56.1558L92.9674 57.4953L91.6286 61.5407C91.4332 62.1314 90.8813 62.5305 90.2593 62.5305C89.6373 62.5305 89.0854 62.1314 88.8899 61.5407L87.5512 57.4953L83.5079 56.1558C82.9176 55.9603 82.5187 55.4081 82.5187 54.7857C82.5187 54.1634 82.9176 53.6109 83.5079 53.4153ZM81.4327 30.9234L83.1649 25.6887C83.387 25.017 84.0148 24.5635 84.7218 24.5635C85.4291 24.5635 86.0566 25.017 86.279 25.6887L88.0109 30.9234C88.0249 30.9656 88.058 30.9983 88.1002 31.0124L93.3317 32.7455C94.003 32.9677 94.4566 33.5955 94.4566 34.3032C94.4566 35.011 94.003 35.6388 93.3317 35.8613L88.1002 37.5941C88.058 37.6082 88.0249 37.6413 88.0109 37.6834L86.279 42.9178C86.0566 43.5895 85.4291 44.0433 84.7218 44.0433C84.0148 44.0433 83.387 43.5895 83.1649 42.9178L81.4327 37.6834C81.419 37.6413 81.3859 37.6082 81.3438 37.5941L76.1119 35.8613C75.4405 35.6388 74.9873 35.011 74.9873 34.3032C74.9873 33.5955 75.4405 32.9677 76.1119 32.7455L81.3438 31.0124C81.3859 30.9983 81.419 30.9656 81.4327 30.9234ZM33.8043 41.8367L9.84331 47.5034C9.50098 47.5844 9.15864 47.6438 8.81738 47.6831V60.3783C8.83044 60.3779 8.84355 60.3777 8.85671 60.3777H31.7253L31.7524 60.3506L32.172 59.9309C33.577 58.5251 35.4451 57.7508 37.4322 57.7508H45.4032C46.7959 57.7508 48.1315 58.3043 49.1164 59.2897L54.2124 64.3885C55.3603 65.5371 55.3724 67.3986 54.2484 68.562C53.0913 69.7598 51.1395 69.7347 49.9622 68.5568L46.2969 64.8895C46.0507 64.6431 45.7168 64.5047 45.3686 64.5047H35.4061L30.4166 68.6936C28.06 70.6722 27.7515 74.2001 29.7289 76.5581C30.409 77.3692 31.2922 77.9589 32.2736 78.2784C32.3845 79.0751 32.6677 79.8362 33.1077 80.5176H31.919C31.5708 80.5176 31.237 80.3791 30.9908 80.1328L27.8745 77.015H8.85671C8.84355 77.015 8.83044 77.0148 8.81738 77.0144V85.0096C8.81738 89.4196 12.3955 93 16.8035 93H34.1572V92.9684H35.6572V93H48.2891V92.9684H49.7888V93H67.1429C71.5504 93 75.1289 89.4196 75.1289 85.0096V79.6183C74.9671 79.6897 74.7881 79.7294 74.5999 79.7294H57.8721L48.9546 87.2162C47.7049 88.2653 45.8418 88.1022 44.7933 86.8519C43.7448 85.6016 43.9077 83.7375 45.1573 82.6884L43.146 84.377C41.8964 85.4261 40.0333 85.263 38.9847 84.0127C37.9362 82.7624 38.0992 80.8983 39.3488 79.8492C38.0992 80.8983 36.2361 80.7352 35.1875 79.4849C34.139 78.2346 34.3019 76.3705 35.5516 75.3214C34.3019 76.3705 32.4389 76.2074 31.3903 74.9571C30.3418 73.7068 30.5047 71.8427 31.7544 70.7936L35.0849 67.9975L36.1161 67.1317H44.8251L48.1478 70.4564C49.2048 71.514 50.6114 72.0964 52.1084 72.0964C53.6053 72.0964 55.0119 71.514 56.069 70.4564C58.0746 68.4495 58.2367 65.2876 56.5582 63.0923H74.5997C74.788 63.0922 74.967 63.1319 75.1289 63.2033V46.2885C75.1289 43.7126 73.0422 41.6247 70.4676 41.6247H49.7888V41.6644H48.2891V41.6247H35.6572V41.6644H34.3435C34.1424 41.6644 33.9563 41.7282 33.8043 41.8367ZM42.4212 52.7895C43.1462 52.7895 43.7339 52.2014 43.7339 51.476V47.138C43.7339 46.4126 43.1462 45.8245 42.4212 45.8245C41.6962 45.8245 41.1084 46.4126 41.1084 47.138V51.476C41.1084 52.2014 41.6962 52.7895 42.4212 52.7895ZM48.5482 55.0187C48.8841 55.0187 49.2201 54.8904 49.4764 54.6339L52.9771 51.1313C53.4898 50.6185 53.4898 49.7868 52.9771 49.2738C52.4645 48.761 51.6332 48.761 51.1206 49.2738L47.6199 52.7764C47.1072 53.2893 47.1072 54.121 47.6199 54.6339C47.8762 54.8904 48.2122 55.0187 48.5482 55.0187ZM36.2959 55.0187C35.96 55.0187 35.6241 54.8904 35.3677 54.6339L31.8669 51.1313C31.3543 50.6184 31.3543 49.7867 31.8669 49.2738C32.3796 48.761 33.2109 48.761 33.7234 49.2738L37.2241 52.7764C37.7368 53.2894 37.7368 54.1211 37.2241 54.6339C36.9679 54.8904 36.6318 55.0187 36.2959 55.0187Z" fill="white"/>
</svg>
'
),
58
);
if ( $this->is_woocommerce_activate ) {
// Add submenu items that correspond to your tabs.
add_submenu_page(
'echo-rewards',
__( 'Referral Settings', 'echo-rewards' ),
__( 'Referral Settings', 'echo-rewards' ),
'manage_options',
'echo-rewards&tab=referral_settings',
array( $this, 'ecre_page_content' )
);
add_submenu_page(
'echo-rewards',
__( 'Reward Settings', 'echo-rewards' ),
__( 'Reward Settings', 'echo-rewards' ),
'manage_options',
'echo-rewards&tab=reward_settings',
array( $this, 'ecre_page_content' )
);
add_submenu_page(
'echo-rewards',
__( 'Reward Management', 'echo-rewards' ),
__( 'Reward Management', 'echo-rewards' ),
'manage_options',
'echo-rewards&tab=reward_management',
array( $this, 'ecre_page_content' )
);
// Add more submenu items for each tab.
add_submenu_page(
'echo-rewards',
__( 'Email Settings', 'echo-rewards' ),
__( 'Email Settings', 'echo-rewards' ),
'manage_options',
'echo-rewards&tab=email_settings',
array( $this, 'ecre_page_content' )
);
add_submenu_page(
'echo-rewards',
__( 'Shortcodes & Widgets', 'echo-rewards' ),
__( 'Shortcodes & Widgets', 'echo-rewards' ),
'manage_options',
'echo-rewards&tab=shortcodes_widgets',
array( $this, 'ecre_page_content' )
);
add_submenu_page(
'echo-rewards',
__( 'Reports & Analytics', 'echo-rewards' ),
__( 'Reports & Analytics', 'echo-rewards' ),
'manage_options',
'echo-rewards&tab=reports_analytics',
array( $this, 'ecre_page_content' )
);
add_submenu_page(
'echo-rewards',
__( 'Help & Documentation', 'echo-rewards' ),
__( 'Help & Documentation', 'echo-rewards' ),
'manage_options',
'echo-rewards&tab=help_documentation',
array( $this, 'ecre_page_content' )
);
}
if ( ! $this->is_pro && ! defined( 'ECHO_REWARDS_PRO_VERSION' ) ) {
// Add the UPGRADE NOW external link as a submenu (proper way).
add_submenu_page(
'echo-rewards',
__( 'UPGRADE NOW', 'echo-rewards' ),
'<span style="color:#74F6DE; font-weight:bold; display:flex; align-items:center;">UPGRADE NOW <svg width="21" height="17" viewBox="0 0 21 17" fill="none" xmlns="http://www.w3.org/2000/svg" style="margin-left:5px;">
<path d="M11.8031 7.65998L10.0832 4.26154L8.36328 7.65998C8.91235 7.69479 9.48587 7.71448 10.0832 7.71448C10.6806 7.71448 11.2541 7.69479 11.8031 7.65998Z" fill="#74F6DE"/>
<path d="M13.5144 3.93494C12.5201 4.00946 11.4444 4.0515 10.3516 4.05748L12.0498 7.41304L13.5144 3.93494Z" fill="#74F6DE"/>
<path d="M17.653 6.59026C18.9389 6.17924 19.7973 5.76447 20.1615 5.57379L17.6881 3.27386L16.8477 6.82967C17.139 6.74925 17.4079 6.66863 17.653 6.59026Z" fill="#74F6DE"/>
<path d="M13.8276 4.06067L12.3281 7.62149C13.8913 7.49138 15.2356 7.24019 16.3213 6.96881L13.8276 4.06067Z" fill="#74F6DE"/>
<path d="M3.84375 6.96881C4.92956 7.24019 6.27375 7.49138 7.83695 7.62149L6.33749 4.06067L3.84375 6.96881Z" fill="#74F6DE"/>
<path d="M14.1172 3.8851L16.5365 6.70643L17.3345 3.33026C17.0102 3.45699 16.4295 3.60181 15.3806 3.74383C14.9842 3.79749 14.5606 3.84456 14.1172 3.8851Z" fill="#74F6DE"/>
<path d="M9.81128 4.05748C8.71845 4.05146 7.64271 4.00942 6.64844 3.93494L8.11304 7.41304L9.81128 4.05748Z" fill="#74F6DE"/>
<path d="M10.0818 3.72416C11.9183 3.72416 13.7348 3.61992 15.1969 3.43067C16.4383 3.26997 17.054 3.09702 17.3042 2.9835C17.0203 2.86618 16.3914 2.68997 15.2275 2.52149C13.739 2.30604 11.9115 2.18738 10.0818 2.18738C8.25205 2.18738 6.42458 2.30604 4.93603 2.52149C3.77219 2.68997 3.14329 2.86618 2.85938 2.9835C3.10952 3.09706 3.7253 3.26997 4.96671 3.43067C6.42872 3.61992 8.24524 3.72416 10.0818 3.72416Z" fill="#74F6DE"/>
<path d="M10.0829 8.0489C9.46633 8.0489 8.87455 8.02821 8.30859 7.99164L10.0829 16.3524L11.8573 7.99164C11.2913 8.02825 10.6996 8.0489 10.0829 8.0489Z" fill="#74F6DE"/>
<path d="M6.04937 3.8851C5.60601 3.84456 5.18232 3.79749 4.78598 3.74383C3.73703 3.60185 3.15632 3.45699 2.83203 3.33026L3.63004 6.70643L6.04937 3.8851Z" fill="#74F6DE"/>
<path d="M12.2038 7.96721L10.4336 16.3083L16.2518 7.32996C15.1416 7.5997 13.78 7.84496 12.2038 7.96721Z" fill="#74F6DE"/>
<path d="M16.7291 7.20893L11.3828 15.4589L19.7324 6.15631C19.2705 6.36617 18.6135 6.63458 17.7705 6.90466C17.4601 7.00414 17.1121 7.1072 16.7291 7.20893Z" fill="#74F6DE"/>
<path d="M3.91406 7.32996L9.73231 16.3083L7.96209 7.96721C6.38594 7.84492 5.02428 7.59966 3.91406 7.32996Z" fill="#74F6DE"/>
<path d="M2.39552 6.90466C1.55255 6.63458 0.895477 6.36617 0.433594 6.15631L8.78319 15.4589L3.43694 7.20893C3.05393 7.1072 2.70594 7.00414 2.39552 6.90466Z" fill="#74F6DE"/>
<path d="M3.31381 6.82963L2.47334 3.27386L0 5.57375C0.364207 5.76442 1.22261 6.1792 2.50845 6.59022C2.75354 6.66859 3.02249 6.74921 3.31381 6.82963Z" fill="#74F6DE"/>
<path d="M1.78207 1.06487C1.84142 1.14328 1.88961 1.23343 1.92864 1.32785C1.96768 1.23347 2.01583 1.14332 2.07522 1.06487C2.21164 0.884688 2.40578 0.753868 2.57995 0.663923C2.40578 0.573979 2.21164 0.443117 2.07522 0.262978C2.01583 0.184569 1.96768 0.0943745 1.92864 0C1.88961 0.0943745 1.84146 0.184528 1.78207 0.262978C1.64565 0.443159 1.45151 0.573979 1.27734 0.663923C1.45151 0.753868 1.64565 0.884688 1.78207 1.06487Z" fill="#74F6DE"/>
<path d="M16.8174 12.8439C16.758 12.7655 16.7099 12.6753 16.6708 12.5809C16.6318 12.6753 16.5836 12.7655 16.5243 12.8439C16.3878 13.0241 16.1937 13.1549 16.0195 13.2449C16.1937 13.3348 16.3879 13.4657 16.5243 13.6458C16.5836 13.7242 16.6318 13.8144 16.6708 13.9088C16.7099 13.8144 16.758 13.7242 16.8174 13.6458C16.9538 13.4656 17.1479 13.3348 17.3221 13.2449C17.1479 13.1549 16.9538 13.0241 16.8174 12.8439Z" fill="#74F6DE"/>
</svg></span>',
'manage_options',
'https://cutt.ly/3ewdS5Go',
null
);
}
}
/**
* Render the Echo Rewards page content.
*/
public function ecre_page_content() {
if ( $this->is_woocommerce_activate ) {
?>
<!-- echo rewards settings dashboard -->
<div class="echo-rewards-settings" id="echo-rewards-settings-dashboard">
</div>
<?php
} else {
?>
<!-- echo rewards settings dashboard -->
<div class="ecre-no-woocommerce" id="ecre_no_woocommerce">
</div>
<?php
}
}
/**
* Highlight the correct submenu item
*
* @param string $submenu_file The submenu file.
* @return string The modified submenu file.
*/
public function highlight_submenu_item( $submenu_file ) {
$screen = get_current_screen();
if ( 'toplevel_page_echo-rewards' === $screen->id ) {
// Get and sanitize the 'tab' parameter.
$tab = filter_input( INPUT_GET, 'tab' );
$tab = $tab ? sanitize_text_field( $tab ) : 'referral_settings';
return 'echo-rewards&tab=' . esc_attr( $tab );
}
return $submenu_file;
}
}
}