service = new Elementor_Design_System_Service(); $this->defaults = new Default_Design_System( $parser, $this->service ); $this->admin_page = new Admin_Page( $parser, $this->service ); } public static function instance(): Plugin { if ( null === self::$instance ) { self::$instance = new self(); } return self::$instance; } public function register(): void { if ( is_admin() ) { $this->defaults->register(); $this->admin_page->register(); add_filter( 'plugin_action_links_' . plugin_basename( V4STUDIO_FILE ), [ $this, 'plugin_action_links' ] ); add_filter( 'plugin_row_meta', [ $this, 'plugin_row_meta' ], 10, 2 ); } /* * Design variables are emitted at REQUEST TIME, inside a cascade layer, and only where * the fallback classes render: the frontend and the Elementor preview iframe. Not the * outer editor chrome, which renders Elementor's interface rather than the document. * * This REPLACES the former CSS-file injection, which is GONE rather than gated. Gating * it would have left red-state regeneration free to write an unlayered V4 block back * into the cached kit stylesheet -- reintroducing both the stale-cache skew and the * ordering dependency the layer exists to remove. See enqueue_fallback_variables_css() * for the full argument. */ add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_fallback_variables_css' ], 100 ); add_action( 'elementor/preview/enqueue_styles', [ $this, 'enqueue_fallback_variables_css' ], 100 ); add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_composition_properties' ], 100 ); add_action( 'elementor/preview/enqueue_styles', [ $this, 'enqueue_composition_properties' ], 100 ); add_action( 'elementor/editor/after_enqueue_styles', [ $this, 'enqueue_composition_properties' ], 100 ); add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_custom_css' ], 100 ); add_action( 'elementor/preview/enqueue_styles', [ $this, 'enqueue_custom_css' ], 100 ); add_action( 'elementor/editor/after_enqueue_styles', [ $this, 'enqueue_custom_css' ], 100 ); add_action( 'elementor/preview/enqueue_styles', [ $this, 'enqueue_editor_custom_css' ], 999 ); add_action( 'elementor/editor/after_enqueue_styles', [ $this, 'enqueue_editor_custom_css' ], 999 ); // After maybe_install() at 15, so a fresh installation has written its defaults and ownership ledger first. add_action( 'admin_init', [ $this, 'maybe_finish_variable_ingest_claims' ], 17 ); } /** * Finish re-adding shipped tokens whose ownership claims never landed. * * WHERE THE AUTHORITY COMES FROM. Not this page load. The operator authorised these exact * labels and ids when they added the tokens back, and the journal is that decision made durable. * This only carries out what has already been decided, and only for candidates that still * match the live source and live Elementor identity -- see Variable_Ingest_Authority. * * WHY HERE. It needs an authenticated administrator, a loaded Elementor and a readable * variable store, which is exactly what admin_init offers and what a front-end request does * not. No visitor can reach it, so no visitor can cause an ownership write. */ public function maybe_finish_variable_ingest_claims(): void { if ( ! Variable_Ingest_Claim_Journal::exists() ) { return; } /* * Capability is checked even though this writes only V4's own bookkeeping: the journal * is only ever created by an administrator action, so a request that could not have * created one has no business completing one. */ if ( ! current_user_can( 'manage_options' ) ) { return; } $settings = self::get_settings(); Variable_Ingest_Authority::recover( (string) ( $settings['variables_css'] ?? '' ), $this->service->get_raw_variable_identity(), Variable_Ownership_Ledger::load() ); /* * Deliberately no stamp here. Recovery decides ownership; whether the design system may * retire its fallback is the verifier's call on its own schedule, and re-running a full * attestation on every admin page load to answer it would be a far worse trade. */ } public function plugin_action_links( array $links ): array { $settings_link = sprintf( '%s', esc_url( admin_url( 'admin.php?page=v4studio' ) ), esc_html__( 'Settings', 'v4studio' ) ); array_splice( $links, 1, 0, [ 'settings' => $settings_link ] ); return $links; } /** A Documentation link after the version and author on this plugin's row in Plugins (there is no Plugin URI). */ public function plugin_row_meta( array $plugin_meta, string $plugin_file ): array { if ( plugin_basename( V4STUDIO_FILE ) !== $plugin_file ) { return $plugin_meta; } $plugin_meta['documentation'] = sprintf( '%s', esc_url( 'https://free.v4.studio/' ), esc_html__( 'Documentation', 'v4studio' ) ); return $plugin_meta; } }