| @@ -18,8 +18,9 @@ | ||
| 18 | 18 | // | MA 02110-1301 USA | |
| 19 | 19 | // +----------------------------------------------------------------------+ |
| 20 | 20 | // | Author: Eugene Manuilov <eugene@manuilov.org> | |
| 21 | 21 | // +----------------------------------------------------------------------+ |
| 22 | + | |
| 22 | 23 | /** |
| 23 | 24 | * Abstract render class implements all routine stuff required for template |
| 24 | 25 | * rendering. |
| 25 | 26 | * |
| @@ -62,9 +63,9 @@ | ||
| 62 | 63 | * @param string $name The name of a property. |
| 63 | 64 | * @return mixed Returns mixed value of a property or NULL if a property doesn't exist. |
| 64 | 65 | */ |
| 65 | 66 | public function __get( $name ) { |
| 66 | - return array_key_exists( $name, $this->_data ) ? $this->_data[ $name ] : null; | |
| 67 | + return array_key_exists( $name, $this->_data ) ? $this->_data[$name] : null; | |
| 67 | 68 | } |
| 68 | 69 | |
| 69 | 70 | /** |
| 70 | 71 | * Checks whether the render has specific property or not. |
| @@ -71,9 +72,9 @@ | ||
| 71 | 72 | * |
| 72 | 73 | * @since 1.0.0 |
| 73 | 74 | * |
| 74 | 75 | * @access public |
| 75 | - * @param string $name The key name. | |
| 76 | + * @param string $name | |
| 76 | 77 | * @return boolean TRUE if the property exists, otherwise FALSE. |
| 77 | 78 | */ |
| 78 | 79 | public function __isset( $name ) { |
| 79 | 80 | return array_key_exists( $name, $this->_data ); |
| @@ -85,12 +86,12 @@ | ||
| 85 | 86 | * @since 1.0.0 |
| 86 | 87 | * |
| 87 | 88 | * @access public |
| 88 | 89 | * @param string $name The name of a property to associate. |
| 89 | - * @param mixed $value The value of a property. | |
| 90 | + * @param mixed $value The value of a property. | |
| 90 | 91 | */ |
| 91 | 92 | public function __set( $name, $value ) { |
| 92 | - $this->_data[ $name ] = $value; | |
| 93 | + $this->_data[$name] = $value; | |
| 93 | 94 | } |
| 94 | 95 | |
| 95 | 96 | /** |
| 96 | 97 | * Unassociates specific property from the render. |
| @@ -100,9 +101,9 @@ | ||
| 100 | 101 | * @access public |
| 101 | 102 | * @param string $name The name of the property to unassociate. |
| 102 | 103 | */ |
| 103 | 104 | public function __unset( $name ) { |
| 104 | - unset( $this->_data[ $name ] ); | |
| 105 | + unset( $this->_data[$name] ); | |
| 105 | 106 | } |
| 106 | 107 | |
| 107 | 108 | /** |
| 108 | 109 | * Renders template. |
| @@ -111,9 +112,9 @@ | ||
| 111 | 112 | * |
| 112 | 113 | * @abstract |
| 113 | 114 | * @access protected |
| 114 | 115 | */ |
| 115 | - abstract protected function _toHTML(); | |
| 116 | + protected abstract function _toHTML(); | |
| 116 | 117 | |
| 117 | 118 | /** |
| 118 | 119 | * Builds template and return it as string. |
| 119 | 120 | * |
| @@ -150,69 +151,5 @@ | ||
| 150 | 151 | public function render() { |
| 151 | 152 | $this->_toHTML(); |
| 152 | 153 | } |
| 153 | 154 | |
| 154 | - /** | |
| 155 | - * Checks if the request is from Gutenberg. | |
| 156 | - * | |
| 157 | - * This happens when the chart is being added to a gutenberg block by inserting a visualizer block. | |
| 158 | - * | |
| 159 | - * @since ? | |
| 160 | - * | |
| 161 | - * @access protected | |
| 162 | - * @return bool | |
| 163 | - */ | |
| 164 | - protected function is_request_from_gutenberg() { | |
| 165 | - global $post; | |
| 166 | - require_once ABSPATH . 'wp-admin/includes/post.php'; | |
| 167 | - if ( $post && function_exists( 'use_block_editor_for_post' ) && use_block_editor_for_post( $post ) ) { | |
| 168 | - do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'This request appears to be from Gutenberg block. Ignoring for chart %d', $post->ID ), 'debug', __FILE__, __LINE__ ); | |
| 169 | - return true; | |
| 170 | - } | |
| 171 | - return false; | |
| 172 | - } | |
| 173 | - | |
| 174 | - /** | |
| 175 | - * Gets the type of chart that is being rendered. | |
| 176 | - * | |
| 177 | - * This is useful if some type-specific functionality needs to be added. | |
| 178 | - * | |
| 179 | - * @since ? | |
| 180 | - * | |
| 181 | - * @access protected | |
| 182 | - * @return string | |
| 183 | - */ | |
| 184 | - protected function get_chart_type( $with_library = false ) { | |
| 185 | - $lib_type = str_replace( 'Visualizer_Render_Sidebar_Type_', '', get_class( $this ) ); | |
| 186 | - if ( $with_library ) { | |
| 187 | - return $lib_type; | |
| 188 | - } | |
| 189 | - | |
| 190 | - $array = explode( '_', $lib_type ); | |
| 191 | - return end( $array ); | |
| 192 | - } | |
| 193 | - | |
| 194 | - /** | |
| 195 | - * Determines if the type of chart can have a particular action. | |
| 196 | - * | |
| 197 | - * @since ? | |
| 198 | - * | |
| 199 | - * @access protected | |
| 200 | - * @return bool | |
| 201 | - */ | |
| 202 | - protected function can_chart_have_action( $action, $chart_id = null ) { | |
| 203 | - $type = null; | |
| 204 | - if ( ! $chart_id ) { | |
| 205 | - $type = $this->get_chart_type( false ); | |
| 206 | - } else { | |
| 207 | - $type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true ); | |
| 208 | - $type = ucwords( $type ); | |
| 209 | - } | |
| 210 | - | |
| 211 | - switch ( $action ) { | |
| 212 | - case 'image': | |
| 213 | - return ! in_array( $type, array( 'Gauge', 'Tabular', 'DataTable', 'Table' ), true ); | |
| 214 | - } | |
| 215 | - | |
| 216 | - return true; | |
| 217 | - } | |
| 218 | -} | |
| 155 | +} | |