AJAX.php
3 months ago
AJAX_Manager.php
4 days ago
Archive_Link.php
3 months ago
Clear_Favorite_Report.php
4 days ago
Click_Tracking_Cache_Cleared.php
3 months ago
Configure_Pruner.php
3 months ago
Copy_Report.php
3 months ago
Create_Campaign.php
2 years ago
Create_Report.php
3 months ago
Delete_Campaign.php
2 years ago
Delete_Data.php
3 months ago
Delete_Link.php
3 months ago
Delete_Module.php
3 months ago
Delete_Report.php
3 months ago
Dismiss_Notice.php
1 year ago
Edit_Link.php
3 months ago
Edit_Module.php
3 months ago
Export_Report_Statistics.php
2 months ago
Export_Report_Table.php
9 months ago
Export_Reports.php
4 days ago
FetchRealTimeData.php
4 days ago
Filter.php
2 months ago
Get_Journey_Timeline.php
6 months ago
Get_Markup_For_Module.php
1 year ago
Get_Markup_For_Modules.php
3 months ago
Import_Reports.php
3 months ago
Migration_Status.php
3 months ago
Pause_Email_Reports.php
3 months ago
Preview_Email.php
2 months ago
Refresh_Modules.php
3 months ago
Rename_Report.php
3 months ago
Reorder_Modules.php
3 months ago
Reset_Analytics.php
3 months ago
Reset_Overview.php
3 months ago
SaveRealTimePreferences.php
4 days ago
Save_Module.php
3 months ago
Save_Report.php
3 months ago
Set_Favorite_Report.php
1 year ago
Set_WooCommerce_Statuses_To_Track.php
3 months ago
Sort_Links.php
3 months ago
Sort_Reports.php
3 months ago
Test_Email.php
2 months ago
Update_Capabilities.php
3 months ago
Update_User_Settings.php
3 months ago
Archive_Link.php
43 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP\AJAX; |
| 4 | |
| 5 | use IAWP\Capability_Manager; |
| 6 | use IAWP\Click_Tracking; |
| 7 | use IAWP\Illuminate_Builder; |
| 8 | use IAWP\Tables; |
| 9 | /** @internal */ |
| 10 | class Archive_Link extends \IAWP\AJAX\AJAX |
| 11 | { |
| 12 | protected function action_name() : string |
| 13 | { |
| 14 | return 'iawp_archive_link'; |
| 15 | } |
| 16 | protected function requires_pro() : bool |
| 17 | { |
| 18 | return \true; |
| 19 | } |
| 20 | protected function requires_write_access() : bool |
| 21 | { |
| 22 | return \true; |
| 23 | } |
| 24 | protected function action_callback() : void |
| 25 | { |
| 26 | if (!Capability_Manager::can_edit()) { |
| 27 | return; |
| 28 | } |
| 29 | $id = $this->get_field('id'); |
| 30 | $link_rule = Click_Tracking\Link_Rule::find($id); |
| 31 | if (\is_null($link_rule)) { |
| 32 | \wp_send_json_error([]); |
| 33 | } |
| 34 | Click_Tracking\Link_Rule_Finder::require_cleared_cache(); |
| 35 | $link_rule->toggle_active(); |
| 36 | Illuminate_Builder::new()->from(Tables::link_rules())->where('is_active', '=', $link_rule->is_active() ? 1 : 0)->increment('position'); |
| 37 | Illuminate_Builder::new()->from(Tables::link_rules())->where('link_rule_id', '=', $link_rule->id())->update(['position' => 0]); |
| 38 | // Send response |
| 39 | $response = \IAWPSCOPED\iawp_render('click-tracking.link', ['link' => $link_rule->to_array(), 'types' => Click_Tracking::types(), 'extensions' => Click_Tracking::extensions(), 'protocols' => Click_Tracking::protocols()]); |
| 40 | echo \wp_json_encode($response); |
| 41 | } |
| 42 | } |
| 43 |