This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Plugin::__construct()

Class constructors – sets all filters and hooks


Source

File: includes/libs/plugin.class.php

	private function __construct(){
		// start the autoloader
		$this->register_autoloader();
		// load dependency files
		$this->load();

		// activation hook to add the rewrite rules for the custom post type
		register_activation_hook( VIMEOTHEQUE_FILE, [
			$this,
			'activation_hook'
		] );

		add_action( 'plugins_loaded', [
			$this,
			'init'
		], 1 );

		// run this admin init on init to have access to earlier hooks
		// priority must be set to run very early so that init hooks set
		// in admin page can also run
		add_action( 'init', [
			$this,
			'admin_init'
		], -9999999 );

		new Amp();
		new Templates_Init();

		add_action(
			'after_setup_theme',
			function(){
				$options = $this->get_options();
				if( $options['enable_templates'] && !current_theme_supports( 'vimeotheque' ) ){
					/**
					 * Support for Video templates.
					 */
					add_theme_support( 'vimeotheque' );

					/**
					 * Support for next video card after the video finishes.
					 */
					add_theme_support( 'vimeotheque-next-video-card' );
				}
			}, 1
		);

		add_filter(
			'vimeotheque\options\get',
			/**
			 * Filter options.
			 *
			 * Filter the plugin options and check if templates are enabled.
			 *
			 * @param array $result             The requested options set.
			 * @param array $all_options        All the plugin options.
			 * @param string $wp_option_name    The WP option name.
			 */
			function( $result, $all_options, $wp_option_name ){

				if( $this->get_options_obj()->get_option_name() == $wp_option_name ){

					if( get_theme_support( 'vimeotheque' ) ){
						$all_options['enable_templates'] = true;
						if( isset( $result['enable_templates'] ) ) {
							$result['enable_templates'] = true;
						}
					}

					if( $all_options['enable_templates'] ) {
						// When templates are enabled, these options will always have the same predefined value.
						$options = [
							'archives'           => false,
							'public'             => true,
							'import_title'       => true,
							'import_description' => 'content',
							'featured_image'      => true
						];

						// Set the options to the predefined value.
						foreach ( $options as $index => $value ) {
							if ( isset( $result[ $index ] ) ) {
								$result[ $index ] = $value;
							}
						}
					}
				}

				return $result;

			}, -999, 3
		);
	}

Start your video site now!

Manage and coordinate your Vimeo channels, albums or videos with your WordPress website. Perfect fit for membership, portfolio, online courses or any type of video collection.

Get Vimeotheque PRO!