loadVars(); $this->enqueueScripts(); parent::render(); } /** * Localize executions script (enqueued earlier on admin_enqueue_scripts by AdminScripts). * * @return void */ public function enqueueScripts(): void { wp_localize_script( AdminScripts::use_raw_assets() ? AdminScripts::HANDLE_EXECUTIONS_JS : AdminScripts::HANDLE_ADMIN_JS, 'AfroitMessagingWorkflowExecutions', array( 'wpTimezone' => wp_timezone_string() ?: 'UTC', 'i18n' => array( 'noEntries' => __( 'No execution entries found.', 'afroit-messaging-workflows' ), 'executionJson' => __( 'Execution JSON', 'afroit-messaging-workflows' ), ), ) ); } private function loadVars(): void { global $wpdb; $per_page = 20; $paged = max( 1, absint( Request::get( 'paged', '1' ) ) ); $offset = ( $paged - 1 ) * $per_page; $table = $wpdb->prefix . 'afromewo_workflow_queue'; $total = (int) $wpdb->get_var( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- custom plugin table; admin list is request-scoped and changes every execution. $wpdb->prepare( 'SELECT COUNT(*) FROM %i', $table ) ); $rows = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- custom plugin table; admin list is request-scoped and changes every execution. $wpdb->prepare( 'SELECT * FROM %i ORDER BY created_at DESC LIMIT %d OFFSET %d', $table, $per_page, $offset ), ARRAY_A ); $this->vars['queue_items'] = is_array( $rows ) ? $rows : array(); $this->vars['total_items'] = $total; $this->vars['per_page'] = $per_page; $this->vars['base_url'] = HubPage::url( array( 'tab' => 'automations', 'section' => 'executed', ) ); } protected function getViewPath() { return AFROMEWO_PLUGIN_DIR . 'includes/Admin/Automation/Views/executions.php'; } }