beans_get_layouts_for_options

Generate layout elements used by Beans 'imageradio' option type.

Added layout should contain a unique ID as the array key and a URL path to its related image as the array value.

beans_get_layouts_for_options( bool $add_default = false )

Return: (array) Layouts ready for Beans 'imageradio' option type.

Parameters

NameTypeRequiredDefaultDescription
$add_defaultboolfalsefalseWhether the 'default_fallback' element is added or not.

Source

function beans_get_layouts_for_options( $add_default = false ) {

	$base = BEANS_ADMIN_ASSETS_URL . 'images/layouts/';

	$layouts = array(
		'c' => $base . 'c.png',
	);

	// Add sidebar primary layouts if the primary widget area is registered.
	if ( $has_primary = beans_has_widget_area( 'sidebar_primary' ) ) {

		$layouts['c_sp'] = $base . 'cs.png';
		$layouts['sp_c'] = $base . 'sc.png';

	}

	// Add sidebar secondary layouts if the primary and secondary widget area are registered.
	if ( $has_primary && beans_has_widget_area( 'sidebar_secondary' ) ) {

		$layouts['c_sp_ss'] = $base . 'css.png';
		$layouts['sp_ss_c'] = $base . 'ssc.png';
		$layouts['sp_c_ss'] = $base . 'scs.png';

	}

	/**
	 * Filter the layouts.
	 *
	 * - $c stands for content.
	 * - $sp stands for sidebar primary.
	 * - $ss stands for 'sidebar secondary.
	 *
	 * @since 1.0.0
	 *
	 * @param array $args An array of layouts.
	 */
	$layouts = apply_filters( 'beans_layouts', $layouts );

	if ( $add_default ) {
		$layouts = array_merge( array(
			'default_fallback' => sprintf(
				__( 'Use Default Layout (%s)',  'tm-beans' ),
				'<a href="' . admin_url( 'customize.php?autofocus[control]=beans_layout' ) . '">' . _x( 'Modify', 'Default layout', 'tm-beans' ) . '</a>'
			),
		), $layouts );
	}

	return $layouts;

}