Google_Maps_Builder_Settings::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
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', 'google-maps-builder' );
22
23
		add_action( 'cmb2_render_lat_lng_default', array( $this, 'cmb2_render_lat_lng_default' ), 10, 2 );
24
25
		//upsell markup
26
		add_action( 'gmb_settings_page_after_logo', array( $this, 'settings_upsell' ) );
27
		add_action( 'gmb_social_media_after_logo', array( $this, 'settings_social_media_upsell' ) );
28
	}
29
30
31
	/**
32
	 * Add links to Plugin listings view
33
	 *
34
	 * @param $links
35
	 *
36
	 * @return mixed
37
	 */
38
	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...
39
40
		if ( $file == GMB_PLUGIN_BASE ) {
41
42
			// Add Widget Page link to our plugin
43
			$settings_link = '<a href="edit.php?post_type=google_maps&page=' . self::$key . '" title="' . __( 'Visit the Google Maps Builder plugin settings page', 'google-maps-builder' ) . '">' . __( 'Settings', 'google-maps-builder' ) . '</a>';
44
			array_unshift( $links, $settings_link );
45
		}
46
47
		return $links;
48
	}
49
50
	/**
51
	 * Add Plugin Meta Links
52
	 *
53
	 * @description: Adds links to the plugin listing page in wp-admin
54
	 *
55
	 * @param $meta
56
	 * @param $file
57
	 *
58
	 * @return array
59
	 */
60
	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...
61
62
		if ( $file == GMB_PLUGIN_BASE ) {
63
			$meta[] = "<a href='http://wordpress.org/support/view/plugin-reviews/google-maps-builder' target='_blank' title='" . __( 'Rate Google Maps Builder on WordPress.org', 'google-maps-builder' ) . "'>" . __( 'Rate Plugin', 'google-maps-builder' ) . "</a>";
64
			$meta[] = "<a href='https://wordimpress.com/documentation/maps-builder-pro/' target='_blank' title='" . __( 'View the plugin documentation', 'google-maps-builder' ) . "'>" . __( 'Documentation', 'google-maps-builder' ) . "</a>";
65
			$meta[] = '<a href="http://wordpress.org/support/plugin/google-maps-builder/" target="_blank" title="' . __( 'Get plugin support via the WordPress community', 'google-maps-builder' ) . '">' . __( 'Support', 'google-maps-builder' ) . '</a>';
66
			$meta[] = '<a href="
67
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', 'google-maps-builder' ) . '" target="_blank">' . __( 'Upgrade to Pro', 'google-maps-builder' ) . ' &raquo;</a>';
68
		}
69
70
		return $meta;
71
	}
72
73
	/**
74
	 * Add upsell in settings page
75
	 *
76
	 * @since 2.1.0
77
	 *
78
	 * @uses "gmb_settings_page_after_logo" action
79
	 */
80
	public function settings_upsell() { ?>
81
		<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 gmb-settings-header-btn">
82
			<?php _e( 'Upgrade to Pro', 'google-maps-builder' ); ?>
83
		</a>
84
		<?php
85
	}
86
87
	/**
88
	 * Add upsell in social media section.
89
	 *
90
	 * @since 2.1.0
91
	 *
92
	 * @uses "gmb_social_media_after_logo" action
93
	 */
94
	public function settings_social_media_upsell() {
95
		?>
96
		<div class="go-pro">
97
			<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-settings-header-btn">
98
				<?php esc_html_e( 'Upgrade to Pro', 'google-maps-builder' ); ?>
99
			</a>
100
		</div>
101
		<?php
102
	}
103
104
	/**
105
	 * Handle main data for the settings page
106
	 *
107
	 * @since 2.1.0
108
	 *
109
	 * @return array
110
	 */
111
	protected function settings_page_data() {
112
		//place holder
113
		$data = array(
114
			'welcome'     => sprintf( '%1s Maps Builder %s', __( 'Welcome to', 'maps-builder-pro' ), Google_Maps_Builder()->meta['Version'] ),
115
			'sub_heading' => $this->sub_heading()
116
		);
117
118
		return $this->view_data( $data, true );
119
	}
120
121
	/**
122
	 * Sub heading markup for settings page
123
	 *
124
	 * @since 2.1.0
125
	 *
126
	 * @return string
127
	 */
128
	protected function sub_heading() {
129
		$out = __( 'Thanks for using Maps Builder. ', 'google-maps-pro' );
130
		$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.', 'google-maps-builder' ), '<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">' );
131
132
		return $out;
133
134
	}
135
136
137
}
138
139