hooks = $hooks; } /* * Hooks table html * @return string */ public function get_hooks_table() { $default_hook = array( 'hookid_1' => array( "position" => "on_image", "hook" => "", "custom" => "", "priority" => "10" ) ); $html = ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= $this->get_hooks( $this->hooks ); $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= '
' . __( 'Label position', 'advanced-woo-labels' ) . '' . __( 'Hook', 'advanced-woo-labels' ) . '' . __( 'Hook priority', 'advanced-woo-labels' ) . '
'; $html .= '' . '+ ' . __( "Add hook", "advanced-woo-labels" ) . ''; $html .= '
'; return $html; } /* * Hook table row html * @return string */ public function get_hooks( $hooks ) { $html = ''; if ( $hooks && ! empty( $hooks ) ) { foreach ($hooks as $hook_id => $hook_args) { $this->hook['id'] = $hook_id; $this->hook['args'] = $hook_args; $position_html = $this->get_field('position'); $hooks_html = $this->get_field('hook'); $hook_custom_html = $this->get_field('custom'); $priority_html = $this->get_field('priority'); $custom_class = in_array( $this->hook['args']['hook'], array( 'custom action', 'custom filter' ) ) ? ' awl-custom' : ''; $html .= ''; $html .= ''; $html .= $position_html; $html .= ''; $html .= ''; $html .= $hooks_html . $hook_custom_html; $html .= ''; $html .= ''; $html .= $priority_html; $html .= ''; $html .= ''; $html .= '–'; $html .= ''; $html .= ''; } } return $html; } /* * Get field html markup * @param $type string Field type * @return string */ private function get_field( $type ) { $this->field_name = "hooks[" . $this->hook['id'] . "][{$type}]"; return call_user_func( array( $this, 'get_hook_' . $type ) ); } /* * Hook position html * @return string */ private function get_hook_position() { $positions = AWL_Helpers::get_labels_positions(); $html = ''; $html .= ''; return $html; } /* * Hooks html * @return string */ private function get_hook_hook() { $hooks = AWL_Helpers::get_woocommerce_hooks(); $hooks[] = 'custom action'; $hooks[] = 'custom filter'; $html = ''; $html .= ''; return $html; } /* * Custom hook html * @return string */ private function get_hook_custom() { $html = ''; $html .= ''; return $html; } /* * Hooks html * @return string */ private function get_hook_priority() { $html = ''; $html .= ''; return $html; } } endif;