Completed
Pull Request — master (#208)
by Devin
20:05
created

Google_Maps_Builder_Settings::settings_page_data()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 9.6666
1
<?php
2
3
/**
4
 * Class Google_Maps_Builder_Settings
5
 */
6
class Google_Maps_Builder_Settings extends Google_Maps_Builder_Core_Settings {
7
8
	/**
9
	 * Option key, and option page slug
10
	 * @var string
11
	 */
12
	protected static $key = 'gmb_settings';
13
14
15
	/**
16
	 * Constructor
17
	 * @since 0.1.0
18
	 */
19
	public function __construct() {
20
		parent::__construct();
21
		$this->page_name = __( 'Google Maps Builder Settings', $this->plugin_slug );
22
23
		$this->plugin_slug = Google_Maps_Builder()->get_plugin_slug();
24
		add_action( 'cmb2_render_lat_lng_default', array( $this, 'cmb2_render_lat_lng_default' ), 10, 2 );
25
26
		//upsell markup
27
		add_action( 'gmb_settings_page_after_logo', array( $this, 'settings_upsell' ) );
28
		add_action( 'gmb_social_media_after_logo', array( $this, 'settings_social_media_upsell' ) );
29
	}
30
31
32
	/**
33
	 * Add links to Plugin listings view
34
	 *
35
	 * @param $links
36
	 *
37
	 * @return mixed
38
	 */
39
	function add_plugin_page_links( $links, $file ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
40
41
		if ( $file == GMB_PLUGIN_BASE ) {
42
43
			// Add Widget Page link to our plugin
44
			$settings_link = '<a href="edit.php?post_type=google_maps&page=' . self::$key . '" title="' . __( 'Visit the Google Maps Builder plugin settings page', $this->plugin_slug ) . '">' . __( 'Settings', $this->plugin_slug ) . '</a>';
45
			array_unshift( $links, $settings_link );
46
		}
47
48
		return $links;
49
	}
50
51
	/**
52
	 * Add Plugin Meta Links
53
	 *
54
	 * @description: Adds links to the plugin listing page in wp-admin
55
	 *
56
	 * @param $meta
57
	 * @param $file
58
	 *
59
	 * @return array
60
	 */
61
	function add_plugin_meta_links( $meta, $file ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
62
63
		if ( $file == GMB_PLUGIN_BASE ) {
64
			$meta[] = "<a href='http://wordpress.org/support/view/plugin-reviews/google-maps-builder' target='_blank' title='" . __( 'Rate Google Maps Builder on WordPress.org', $this->plugin_slug ) . "'>" . __( 'Rate Plugin', $this->plugin_slug ) . "</a>";
65
			$meta[] = "<a href='https://wordimpress.com/documentation/maps-builder-pro/' target='_blank' title='" . __( 'View the plugin documentation', $this->plugin_slug ) . "'>" . __( 'Documentation', $this->plugin_slug ) . "</a>";
66
			$meta[] = '<a href="http://wordpress.org/support/plugin/google-maps-builder/" target="_blank" title="' . __( 'Get plugin support via the WordPress community', $this->plugin_slug ) . '">' . __( 'Support', $this->plugin_slug ) . '</a>';
67
			$meta[] = '<a href="
68
https://wordimpress.com/plugins/maps-builder-pro?utm_source=MBF&utm_medium=BANNER&utm_content=LISTING&utm_campaign=MBF%20LISTING" title="' . __( 'Upgrade to Maps Builder Pro', $this->plugin_slug ) . '" target="_blank">' . __( 'Upgrade to Pro', $this->plugin_slug ) . ' &raquo;</a>';
69
		}
70
71
		return $meta;
72
	}
73
74
	/**
75
	 * Add upsell in settings page
76
	 *
77
	 * @since 2.1.0
78
	 *
79
	 * @uses "gmb_settings_page_after_logo" action
80
	 */
81
	public function settings_upsell() { ?>
82
		<a href="https://wordimpress.com/plugins/maps-builder-pro?utm_source=MBF&utm_medium=BANNER&utm_content=SETTINGS&utm_campaign=MBF%20Settings" target="_blank" class="button button-primary gmb-orange-btn gmb-settings-header-btn">
83
			<?php _e( 'Upgrade to Pro', $this->plugin_slug ); ?>
84
		</a>
85
		<?php
86
	}
87
88
	/**
89
	 * Add upsell in social media section
90
	 *
91
	 * @since 2.1.0
92
	 *
93
	 * @uses "gmb_social_media_after_logo" action
94
	 */
95
	public function settings_social_media_upsell() {
96
		?>
97
		<div class="go-pro">
98
			<a href="https://wordimpress.com/plugins/maps-builder-pro?utm_source=MBF&amp;utm_medium=BANNER&amp;utm_content=SETTINGS&amp;utm_campaign=MBF%20Settings" target="_blank" class="button button-primary button-small gmb-orange-btn gmb-settings-header-btn">
99
				<?php esc_html_e( 'Upgrade to Pro', 'google-maps-builder' ); ?>
100
			</a>
101
		</div>
102
		<?php
103
	}
104
105
	/**
106
	 * Handle main data for the settings page
107
	 *
108
	 * @since 2.1.0
109
	 *
110
	 * @return array
111
	 */
112
	protected function settings_page_data() {
113
		//place holder
114
		$data = array(
115
			'welcome'     => sprintf( '%1s Maps Builder %s', __( 'Welcome to', 'maps-builder-pro' ), Google_Maps_Builder()->meta['Version'] ),
116
			'sub_heading' => $this->sub_heading()
117
		);
118
119
		return $this->view_data( $data, true );
120
	}
121
122
	/**
123
	 * Sub heading markup for settings page
124
	 *
125
	 * @since 2.1.0
126
	 *
127
	 * @return string
128
	 */
129
	protected function sub_heading() {
130
		$out = __( 'Thanks for using Maps Builder', 'google-maps-pro' );
131
		$out .= sprintf( __( 'To get started, read over the %1$sdocumentation%2$s, take a gander at the settings, and build yourself some maps! If you enjoy this plugin please consider telling a friend, rating it %3$s5-stars%2$s, or purchasing the %4$sPro%2$s edition.', $this->plugin_slug ), '<a href="https://wordimpress.com/documentation/maps-builder-pro/" target="_blank">', '</a>', '<a href="https://wordpress.org/support/view/plugin-reviews/google-maps-builder?filter=5#postform" target="_blank">', '<a href="https://wordimpress.com/plugins/maps-builder-pro?utm_source=MBF&amp;utm_medium=BANNER&amp;utm_content=SETTINGS&amp;utm_campaign=MBF%20Settings" target="_blank">' );
132
133
		return $out;
134
135
	}
136
137
138
}
139
140