'; esc_html_e( 'ShapeOptions requires WooCommerce to be installed and active.', 'shapeoptions' ); echo '

'; } ); return; } require_once SHAPEOPTIONS_PATH . 'includes/class-shapeoptions-plugin.php'; Shapeoptions_Plugin::instance(); } add_action( 'plugins_loaded', 'shapeoptions_init', 10 ); /** * Add a Settings link to the plugin's row on the Plugins screen. * * Registered at file level rather than inside shapeoptions_init() so the row * still renders normally when WooCommerce is missing — in that case the link * is simply omitted, because the page it points at is not registered either. * * @param string[] $links Existing action links. * @return string[] */ function shapeoptions_plugin_action_links( $links ) { if ( ! class_exists( 'WooCommerce' ) || ! current_user_can( 'manage_woocommerce' ) ) { return $links; } $settings = sprintf( '%s', esc_url( admin_url( 'edit.php?post_type=shapeoptions_group&page=shapeoptions-style-settings' ) ), esc_html__( 'Settings', 'shapeoptions' ) ); // Prepended: WordPress shows Deactivate/Delete last by convention. return array_merge( array( 'shapeoptions-settings' => $settings ), $links ); } add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'shapeoptions_plugin_action_links' ); /** * Main accessor to the plugin container, for add-ons and themes. * * @return Shapeoptions_Plugin|null */ function shapeoptions() { return class_exists( 'Shapeoptions_Plugin' ) ? Shapeoptions_Plugin::instance() : null; } if ( ! function_exists( 'shapeoptions_asset_version' ) ) { /** * Cache-busting version for an enqueued asset. In WP_DEBUG (or when * SHAPEOPTIONS_DEV is explicitly on) this returns the file's last-modified * time so every save auto-busts cache without touching the plugin version — * handy while developing. Otherwise it returns the plugin version as usual, * which is what production sites should ship with. * * Guarded by function_exists so an add-on shipping an identical copy in * its own bootstrap stays compatible — whichever plugin loads first * wins, the same pattern as the SHAPEOPTIONS_VERSION guard above. * * @param string $abs_path Absolute path to the asset file (e.g. SHAPEOPTIONS_PATH . 'assets/css/shapeoptions-frontend.css'). * @param string $fallback Version to use outside dev mode (SHAPEOPTIONS_VERSION). * @return string */ function shapeoptions_asset_version( $abs_path, $fallback ) { $dev = ( defined( 'SHAPEOPTIONS_DEV' ) && SHAPEOPTIONS_DEV ) || ( defined( 'WP_DEBUG' ) && WP_DEBUG ); if ( $dev ) { $mtime = is_file( $abs_path ) ? filemtime( $abs_path ) : false; if ( $mtime ) { return (string) $mtime; } } return $fallback; } }