You are here

public static function ShareaholicUtilities::set_default_location_settings in Share Buttons, Related Posts, Content Analytics - Shareaholic 8

Same name and namespace in other branches
  1. 7.3 utilities.php \ShareaholicUtilities::set_default_location_settings()

Given an object, set the default on/off locations for share buttons and recommendations

2 calls to ShareaholicUtilities::set_default_location_settings()
ShareaholicUtilities::get_or_create_api_key in ./utilities.php
Returns the api key or creates a new one.
ShareaholicUtilities::reset_settings in ./utilities.php
Restore the plugin settings

File

./utilities.php, line 339

Class

ShareaholicUtilities

Code

public static function set_default_location_settings($location_name_ids) {
  $turned_on_share_buttons_locations = self::get_default_sb_on_locations();
  $turned_off_share_buttons_locations = self::get_default_sb_off_locations();
  $turned_on_recommendations_locations = self::get_default_rec_on_locations();
  $turned_off_recommendations_locations = self::get_default_rec_off_locations();
  $turned_on_share_buttons_keys = array();
  foreach ($turned_on_share_buttons_locations as $loc) {
    $turned_on_share_buttons_keys[] = $loc['name'];
  }
  $turned_on_recommendations_keys = array();
  foreach ($turned_on_recommendations_locations as $loc) {
    $turned_on_recommendations_keys[] = $loc['name'];
  }
  $turned_off_share_buttons_keys = array();
  foreach ($turned_off_share_buttons_locations as $loc) {
    $turned_off_share_buttons_keys[] = $loc['name'];
  }
  $turned_off_recommendations_keys = array();
  foreach ($turned_off_recommendations_locations as $loc) {
    $turned_off_recommendations_keys[] = $loc['name'];
  }
  $turn_on = array(
    'share_buttons' => self::associative_array_slice($location_name_ids['share_buttons'], $turned_on_share_buttons_keys),
    'recommendations' => self::associative_array_slice($location_name_ids['recommendations'], $turned_on_recommendations_keys),
  );
  $turn_off = array(
    'share_buttons' => self::associative_array_slice($location_name_ids['share_buttons'], $turned_off_share_buttons_keys),
    'recommendations' => self::associative_array_slice($location_name_ids['recommendations'], $turned_off_recommendations_keys),
  );
  ShareaholicUtilities::turn_on_locations($turn_on, $turn_off);
}