Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

MDG_Generic

Dan Holloran edited this page Mar 11, 2014 · 1 revision

MDG_Generic

Contains methods/properties that can be used by all classes.

All classes should at the very minimum extend MDG_Generic so they can have easy access to all helper methods/properties.

  • Class name: MDG_Generic
  • Namespace:

Methods

\MDG_Generic::__construct()

Void MDG_Generic::\MDG_Generic::__construct()()

Class Constructor

  • Visibility: public

\MDG_Generic::is_localhost()

boolean MDG_Generic::\MDG_Generic::is_localhost()()

Checks if the current host is localhost.

  • Visibility: public

\MDG_Generic::is_staging()

boolean MDG_Generic::\MDG_Generic::is_staging()()

Checks if the current host is a staging site.

  • Visibility: public

\MDG_Generic::get_id_by_slug()

integer MDG_Generic::\MDG_Generic::get_id_by_slug()(string $slug)

Retrieves a page/post/custom post type ID when provided a slug.

  • Visibility: public

Arguments

  • $slug string - <p>The slug of the page/post/custom post type you want an ID for.</p>

\MDG_Generic::make_dummy_content()

Void MDG_Generic::\MDG_Generic::make_dummy_content()(string $post_type, string $title, integer $count, array $options)

Adds testing post content to the supplied post type.

  • Visibility: public

Arguments

  • $post_type string - <p>Required, Name of the post type to create content for.</p>
  • $title string - <p>Required, The title base you want to use without a trailing space, the post count will be appended to the end.</p>
  • $count integer - <p>Required, The amount of posts you want to be added.</p>
  • $options array - <p>Optional, options to customize post generation.</p>

\MDG_Generic::truncate_string()

string MDG_Generic::\MDG_Generic::truncate_string()(string $string, integer $limit, string $break, string $pad)

Truncates a string with the supplied information

Example: global $mdg_generic; $mdg_generic->truncate( $string, 30, " " )

  • Visibility: public

Arguments

  • $string string - <p>The string to be truncated</p>
  • $limit integer - <p>The length of the truncated string</p>
  • $break string - <p>The break point</p>
  • $pad string - <p>The string padding to use</p>

\MDG_Generic::pagination()

string MDG_Generic::\MDG_Generic::pagination()(string $max_num_pages, integer $range, boolean $output)

Creates and optionally outputs pagination

  • Visibility: public

Arguments

  • $max_num_pages string - <p>Optional. The amount of pages to be paginated through, defaults to the global $wp_query->max_num_pages.</p>
  • $range integer - <p>Optional. The minimum amount of items to show</p>
  • $output boolean - <p>Optional. Output the content</p>

\MDG_Generic::get_youtube_id()

\[type] MDG_Generic::\MDG_Generic::get_youtube_id()(string $embed)

Retrieves the YouTube video ID from the supplied embed code

  • Visibility: public

Arguments

  • $embed string - <p>YouTube embed code</p>

\MDG_Generic::clean_multi_input()

array MDG_Generic::\MDG_Generic::clean_multi_input()(string $multi_input)

Cleans the multi input meta field.

  • Visibility: public

Arguments

  • $multi_input string - <p>The multi input meta value.</p>

\MDG_Generic::group_multi_input()

array MDG_Generic::\MDG_Generic::group_multi_input()(string $multi_input)

Groups the multi input meta field.

  • Visibility: public

Arguments

  • $multi_input string - <p>The multi input meta value.</p>

\MDG_Generic::get_attachment_id_from_src()

integer MDG_Generic::\MDG_Generic::get_attachment_id_from_src()(string $attachment_url)

Get attachment ID from src url

  • Visibility: public

Arguments

  • $attachment_url string - <p>Absolute URI to an attachment</p>

MDG_Sidebar

Determines whether or not to display the sidebar based on an array of conditional tags or page templates.

If any of the is_* conditional tags or is_page_template(template_file) checks return true, the sidebar will NOT be displayed.

  • Class name: MDG_Sidebar
  • Namespace:

Properties

$conditionals

private array $conditionals

WordPress conditional tags to check against.

  • Visibility: private

$templates

private array $templates

Page template checks (via is_page_template())

  • Visibility: private

$display

public boolean $display = true

If the sidebar should be displayed.

  • Visibility: public

Methods

\MDG_Sidebar::__construct()

mixed MDG_Sidebar::\MDG_Sidebar::__construct()(array $conditionals, array $templates)

Class constructor.

  • Visibility: public

Arguments

  • $conditionals array - <p>WordPress conditional tags to check against.</p>
  • $templates array - <p>Page template checks (via is_page_template())</p>

\MDG_Sidebar::check_conditional_tag()

boolean MDG_Sidebar::\MDG_Sidebar::check_conditional_tag()(string $conditional_tag)

Checks the supplied conditional tag.

  • Visibility: private

Arguments

  • $conditional_tag string - <p>The conditional tag to check against.</p>

\MDG_Sidebar::check_page_template()

boolean MDG_Sidebar::\MDG_Sidebar::check_page_template()(string $page_template)

Checks the supplied page template.

  • Visibility: private

Arguments

  • $page_template string - <p>Page template to check against.</p>
Clone this wiki locally