Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808

Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813
PUM_Modules_Admin_Bar::toolbar_links( WP_Admin_Bar $wp_admin_bar )

Add additional toolbar menu items to the front end.


Description Description


Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808

Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813

Parameters Parameters

$wp_admin_bar

(Required)


Top ↑

Source Source

File: includes/modules/admin-bar.php

	public static function toolbar_links( $wp_admin_bar ) {

		if ( ! self::should_render() ) {
			return;
		}

		$wp_admin_bar->add_node( array(
			'id'     => 'popup-maker',
			'title'  => __( 'Popup Maker', 'popup-maker' ),
			'href'   => '#popup-maker',
			'meta'   => array( 'class' => 'popup-maker-toolbar' ),
			'parent' => false,
		) );

		$wp_admin_bar->add_node( array(
			'id'     => 'popups',
			'title'  => __( 'Popups', 'popup-maker' ),
			'href'   => '#',
			'parent' => 'popup-maker',
		) );

		$popups = PUM_Modules_Admin_Bar::loaded_popups();

		if ( count( $popups ) ) {

			foreach ( $popups as $popup ) {
				/** @var WP_Post $popup */

				$node_id = 'popup-' . $popup->ID;

				$can_edit = current_user_can( 'edit_post', $popup->ID );

				$edit_url = $can_edit ? admin_url( 'post.php?post=' . $popup->ID . '&action=edit' ) : '#';

				// Single Popup Menu Node
				$wp_admin_bar->add_node( array(
					'id'     => $node_id,
					'title'  => esc_html( $popup->post_title ),
					'href'   => $edit_url,
					'parent' => 'popups',
				) );

				// Trigger Link
				$wp_admin_bar->add_node( array(
					'id'     => $node_id . '-open',
					'title'  => __( 'Open Popup', 'popup-maker' ),
					'meta'   => array(
						'onclick' => 'PUM.open(' . $popup->ID . '); return false;',
					),
					'href'   => '#popup-maker-open-popup-' . $popup->ID,
					'parent' => $node_id,
				) );

				$wp_admin_bar->add_node( array(
					'id'     => $node_id . '-close',
					'title'  => __( 'Close Popup', 'popup-maker' ),
					'meta'   => array(
						'onclick' => 'PUM.close(' . $popup->ID . '); return false;',
					),
					'href'   => '#popup-maker-close-popup-' . $popup->ID,
					'parent' => $node_id,
				) );

				if ( pum_get_popup( $popup->ID )->has_conditions( array( 'js_only' => true ) ) ) {
					$wp_admin_bar->add_node( array(
						'id'     => $node_id . '-conditions',
						'title'  => __( 'Check Conditions', 'popup-maker' ),
						'meta'   => array(
							'onclick' => 'alert(PUM.checkConditions(' . $popup->ID . ') ? "Pass" : "Fail"); return false;',
						),
						'href'   => '#popup-maker-check-conditions-popup-' . $popup->ID,
						'parent' => $node_id,
					) );
				}

				$wp_admin_bar->add_node( array(
					'id'     => $node_id . '-reset-cookies',
					'title'  => __( 'Reset Cookies', 'popup-maker' ),
					'meta'   => array(
						'onclick' => 'PUM.clearCookies(' . $popup->ID . '); alert("' . __( 'Success', 'popup-maker' ) . '"); return false;',
					),
					'href'   => '#popup-maker-reset-cookies-popup-' . $popup->ID,
					'parent' => $node_id,
				) );

				if ( $can_edit ) {
					// Edit Popup Link
					$wp_admin_bar->add_node( array(
						'id'     => $node_id . '-edit',
						'title'  => __( 'Edit Popup', 'popup-maker' ),
						'href'   => $edit_url,
						'parent' => $node_id,
					) );
				}

			}
		} else {
			$wp_admin_bar->add_node( array(
				'id'     => 'no-popups-loaded',
				'title'  => __( 'No Popups Loaded', 'popup-maker' ) . '<strong style="color:#fff; margin-left: 5px;">?</strong>',
				'href'   => 'https://docs.wppopupmaker.com/article/265-my-popup-wont-work-how-can-i-fix-it?utm_campaign=contextual-help&utm_medium=inline-doclink&utm_source=plugin-admin-bar&utm_content=no-popups-loaded',
				'parent' => 'popups',
				'meta'   => array(
					'target' => '_blank',
				),

			) );
		}

		if ( current_user_can( 'edit_posts' ) ) {
			$wp_admin_bar->add_node( array(
				'id'     => 'all-popups',
				'title'  => __( 'All Popups', 'popup-maker' ),
				'href'   => admin_url( 'edit.php?post_type=popup' ),
				'parent' => 'popup-maker',
			) );
			$wp_admin_bar->add_node( array(
				'id'     => 'new-popups', // Just `new-popup` moves this to the top of the menu for some reason. Leave the `s` to keep it in the right place.
				'title'  => __( 'Create New Popup', 'popup-maker' ),
				'href'   => admin_url( 'post-new.php?post_type=popup' ),
				'parent' => 'popup-maker',
			) );
		}

		/**
		 * Tools
		 */
		$wp_admin_bar->add_node( array(
			'id'     => 'pum-tools',
			'title'  => __( 'Tools', 'popup-maker' ),
			'href'   => '#popup-maker-tools',
			'parent' => 'popup-maker',
		) );

		$wp_admin_bar->add_node(
			array(
				'id'     => 'flush-popup-cache',
				'title'  => __( 'Flush Popup Cache', 'popup-maker' ),
				'href'   => add_query_arg( 'flush_popup_cache', 'yes' ),
				'parent' => 'pum-tools',
			)
		);

		/**
		 * Get Selector
		 */
		$wp_admin_bar->add_node( array(
			'id'     => 'pum-get-selector',
			'title'  => __( 'Get Selector', 'popup-maker' ),
			'href'   => '#popup-maker-get-selector-tool',
			'parent' => 'pum-tools',
		) );
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.