__('General', 'wp-ultimo'), 'desc' => __('General', 'wp-ultimo'), 'type' => 'header', ); $fields['title'] = array( 'type' => 'text', 'title' => __('Title', 'wp-ultimo'), 'value' => __('Invoices', 'wp-ultimo'), 'desc' => __('Leave blank to hide the title completely.', 'wp-ultimo'), 'tooltip' => '', ); $fields['limit'] = array( 'type' => 'int', 'title' => __('Limit', 'wp-ultimo'), 'value' => 10, 'desc' => __('Limit the number of invoices to show.', 'wp-ultimo'), 'tooltip' => '', ); return $fields; } // end fields; /** * The list of keywords for this element. * * Return an array of strings with keywords describing this * element. Gutenberg uses this to help customers find blocks. * * e.g.: * return array( * 'WP Ultimo', * 'Invoices', * 'Form', * 'Cart', * ); * * @since 2.0.0 * @return array */ public function keywords() { return array( 'WP Ultimo', 'Invoices', 'Form', 'Cart', ); } // end keywords; /** * List of default parameters for the element. * * If you are planning to add controls using the fields, * it might be a good idea to use this method to set defaults * for the parameters you are expecting. * * These defaults will be used inside a 'wp_parse_args' call * before passing the parameters down to the block render * function and the shortcode render function. * * @since 2.0.0 * @return array */ public function defaults() { return array( 'title' => __('Invoices', 'wp-ultimo'), 'limit' => 0, ); } // end defaults; /** * Loads the required scripts. * * @since 2.0.0 * @return void */ public function register_scripts() { wp_enqueue_script('wu-ajax-list-table'); } // end register_scripts; /** * Loads dependencies for the render. * * @since 2.0.0 * @return void */ public function dependencies() { if (!function_exists('convert_to_screen')) { require_once ABSPATH . 'wp-admin/includes/template.php'; } // end if; if (!function_exists('get_column_headers')) { require_once ABSPATH . 'wp-admin/includes/class-wp-screen.php'; require_once ABSPATH . 'wp-admin/includes/screen.php'; } // end if; if (!function_exists('wu_responsive_table_row')) { require wu_path('/inc/functions/admin.php'); } // end if; } // end dependencies; /** * Runs early on the request lifecycle as soon as we detect the shortcode is present. * * @since 2.0.0 * @return void */ public function setup() { $this->membership = WP_Ultimo()->currents->get_membership(); if (!$this->membership) { $this->set_display(false); return; } // end if; } // end setup; /** * Allows the setup in the context of previews. * * @since 2.0.0 * @return void */ public function setup_preview() { $this->membership = wu_mock_membership(); } // end setup_preview; /** * The content to be output on the screen. * * Should return HTML markup to be used to display the block. * This method is shared between the block render method and * the shortcode implementation. * * @since 2.0.0 * * @param array $atts Parameters of the block/shortcode. * @param string|null $content The content inside the shortcode. * @return string */ public function output($atts, $content = null) { $atts['membership'] = $this->membership; return wu_get_template_contents('dashboard-widgets/invoices', $atts); } // end output; } // end class Invoices_Element;