PluginProbe
Plugin Detective – Troubleshooting Conflicts / 1.2.13
Plugin Detective – Troubleshooting Conflicts v1.2.13
1.2.33 1.2.32 1.2.31 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2 1.2.1 1.2.10 1.2.12 1.2.13 1.2.14 1.2.16 1.2.19 1.2.20 1.2.22 1.2.23 1.2.24 1.2.25 All 53 releases
plugin-detective / troubleshoot / includes / class-clues.php

class-clues.php in Plugin Detective – Troubleshooting Conflicts 1.2.13, at troubleshoot/includes/class-clues.php

118 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Troubleshoot Clues.
4 *
5 * @since 0.0.0
6 * @package Troubleshoot
7 */
8
9 /**
10 * Troubleshoot Clues.
11 *
12 * @since 0.0.0
13 */
14 class PDT_Clues {
15 /**
16 * Parent plugin class.
17 *
18 * @since 0.0.0
19 *
20 * @var Troubleshoot
21 */
22 protected $plugin = null;
23
24 /**
25 * Constructor.
26 *
27 * @since 0.0.0
28 *
29 * @param Troubleshoot $plugin Main plugin object.
30 */
31 public function __construct( $plugin ) {
32 $this->plugin = $plugin;
33 $this->hooks();
34 }
35
36 /**
37 * Initiate our hooks.
38 *
39 * @since 0.0.0
40 */
41 public function hooks() {
42
43 }
44
45 public function get( $args ) {
46
47 }
48
49 public function get_id_from_args( $args ) {
50 $case = $this->plugin->cases->get_active();
51 if ( empty( $case['clues']['0'] ) ) {
52 return null;
53 }
54
55 // If specified, make sure that data is there
56 if ( !empty( $args['id'] ) && $case['clues'][(int)$args['id']] ) {
57 return (int)$args['id'];
58 }
59
60 // Use latest clue by default
61 return count( $case['clues'] ) - 1;
62 }
63
64 public function create( $args ) {
65 if ( !isset( $args['outcome'] ) ) {
66 return new WP_Error( 'outcome', __( 'outcome field required' , 'plugin-detective' ) );
67 }
68
69 $case = $this->plugin->cases->get_active();
70 if ( is_a( $case, 'WP_Error' ) ) {
71 return $case;
72 }
73
74 $active_plugins = array();
75 $plugins = $this->plugin->installed->get_plugins();
76 foreach ($plugins as $key => $plugin) {
77 if ( empty( $plugin['Active'] ) ) {
78 continue;
79 }
80
81 $active_plugins[] = $plugin['plugin_file'];
82 }
83
84 $case['clues'][] = array(
85 'outcome' => $args['outcome'],
86 'active_plugins' => $active_plugins,
87 'cleared_suspects' => $case['cleared_suspects'],
88 'prime_suspects' => $case['prime_suspects'],
89 'culprits' => $case['culprits'],
90 'date_created' => gmdate( 'Y-m-d H:i:s' ),
91 );
92
93 $case = $this->plugin->cases->update( array(
94 'clues' => $case['clues'],
95 ) );
96
97 return $this->plugin->cases->review( $case );
98 }
99
100 public function update( $args ) {
101
102 }
103
104 public function delete( $args ) {
105 $case = $this->plugin->cases->get_active();
106 if ( is_a( $case, 'WP_Error' ) ) {
107 return $case;
108 }
109
110 $clue_id = $this->get_id_from_args( $args );
111 unset( $case['clues'][$clue_id] );
112
113 return $this->plugin->cases->update( array(
114 'clues' => $case['clues'],
115 ) );
116 }
117 }
118