Advertisement:

Author Topic: Changing category icons from FontAwesome (metro theme)  (Read 901 times)

cmaltais

  • Newbie
  • *
  • Posts: 14
Changing category icons from FontAwesome (metro theme)
« on: September 27, 2016, 10:34:00 pm »
Metro theme has nice control of category icons from the admin panel but it limits you to using FontAwesome icon class. Does anyone how to modify this feature so I can use any image in my library for an icon? I've included function.php code. Thanks in advance

 define('METRO_THEME_VERSION', '1.3.1');
   
    // install update options
    function metro_theme_install() {
      $current_version = osc_get_preference('version', 'metro');
      if( $current_version != METRO_THEME_VERSION ) {
         /* Theme Settings */
         osc_set_preference('keyword_placeholder', __('Search', 'metro'), 'metro');
         osc_set_preference('footer_link',1,'metro','BOOLEAN');
         osc_set_preference('footer_info',__('Copyright © '. date("Y") .' '. osc_page_title().'. All rights reserved.', 'metro'),'metro');
         osc_set_preference('version',METRO_THEME_VERSION,'metro');
         
         /* Social Networking */
         osc_set_preference('facebook','https://www.facebook.com/OSClass','metro');
         osc_set_preference('google','https://plus.google.com/+OsclassOrg','metro');
         osc_set_preference('twitter','https://twitter.com/osclass','metro');
         
         /* Bx Slider */
         osc_set_preference('show_only',0, 'metro','INTEGER');
         osc_set_preference('bx_option',1, 'metro','BOOLEAN');
         
         /* Color Scheme */
         osc_set_preference('color_scheme','red', 'metro');
         osc_set_preference('color_switcher',1, 'metro','BOOLEAN');
         
         /* Seed Category Icon */
         osc_set_preference('cat-1','fa-wrench', 'metro');
         osc_set_preference('cat-2','fa-automobile', 'metro');
         osc_set_preference('cat-3','fa-book', 'metro');
         osc_set_preference('cat-4','fa-building', 'metro');
         osc_set_preference('cat-5','fa-wrench', 'metro');
         osc_set_preference('cat-6','fa-users', 'metro');
         osc_set_preference('cat-7','fa-user', 'metro');
         osc_set_preference('cat-8','fa-suitcase', 'metro');
         
         
         /* Ad Banner */
         $banner1 = '<img src="'. osc_current_web_theme_url('images/300x250.png') .'">';
         osc_set_preference('home_sidebar_ads',$banner1, 'metro');
         osc_set_preference('item_sidebar_ads',$banner1, 'metro');
         
         $banner2 = '<img src="'. osc_current_web_theme_url('images/728x90.png') .'">';
         osc_set_preference('search_list_ads',$banner2, 'metro');
         
      }
    }
   metro_theme_install();
   
   osc_admin_menu_appearance(__('Header logo', 'metro'), osc_admin_render_theme_url('oc-content/themes/metro/admin/header.php') , 'header_metro');
    osc_admin_menu_appearance(__('Theme settings', 'metro'), osc_admin_render_theme_url('oc-content/themes/metro/admin/settings.php'), 'settings_metro');
   osc_admin_menu_appearance(__('Carousel Settings', 'metro'), osc_admin_render_theme_url('oc-content/themes/metro/jquery.bxslider/jquery.bxslider.php'), 'carousel_metro');
   
    function metro_delete() {
        Preference::newInstance()->delete(array('s_section' => 'metro'));
    }
   osc_add_hook('theme_delete_metro', 'metro_delete');
   
   /* Change Color Scheme */
   function metro_color_scheme(){
      if(osc_get_preference('color_switcher', 'metro')){
         /* Color Schemes */
         $color_schemes = array(
            'red','pink','purple','deep-purple','indigo','blue','light-blue','cyan','teal','green','light-green','lime','yellow','amber','orange','deep-orange','brown','grey','light-grey','blue-grey'
         );
         $color_scheme = Params::getParam('switch-color');
         if (in_array($color_scheme, $color_schemes)) {
            Cookie::newInstance()->set_expires(time() + 3600 );
            Cookie::newInstance()->push('metro',$color_scheme );
            Cookie::newInstance()->set();
            osc_redirect_to(osc_base_url());
         }
      }
   }
   osc_add_hook('before_html', 'metro_color_scheme');
   
   /* Category Icon */
   function metro_category_icon($cat_id = null){
      if( !Category::newInstance()->isRoot($cat_id) ) {
         $parent_id = Category::newInstance()->findRootCategory($cat_id);
         $cat_id = $parent_id['pk_i_id'];
      }
      return osc_get_preference('cat-'.$cat_id, 'metro');
   }

   /* Category URI */
   function metro_item_category_url($cat_id = null) {
      View::newInstance()->_erase('subcategories') ;
      View::newInstance()->_erase('categories') ;
      if( !Category::newInstance()->isRoot($cat_id) ) {
         $parent_id = Category::newInstance()->findRootCategory($cat_id);
         $cat_id = $parent_id['pk_i_id'];
      }
      View::newInstance()->_exportVariableToView('category', Category::newInstance()->findByPrimaryKey($cat_id)) ;
      $url = osc_search_category_url() ;
      View::newInstance()->_erase('category') ;
      return $url;
   }
   
   /* Carousel Settings */
   function metro_bxslider_settings(){
      if(Params::getParam('action_specific') == 'bxslider' ){
         $show_only = Params::getParam('show_only');
         Preference::newInstance()->update(array("s_value" => $show_only),array("s_section" => "metro", "s_name" => "show_only"));
         $bx_option = Params::getParam('bx_option');
         Preference::newInstance()->update(array("s_value" => $bx_option),array("s_section" => "metro", "s_name" => "bx_option"));

         osc_add_flash_ok_message(__('Carousel updated correctly', 'metro'), 'admin');
         osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/metro/jquery.bxslider/jquery.bxslider.php'));
      }
   }
   osc_add_hook('init_admin', 'metro_bxslider_settings');
   
   function metro_is_fineuploader() {
      return Scripts::newInstance()->registered['jquery-fineuploader'] && method_exists('ItemForm', 'ajax_photos');
   }
   if (metro_is_fineuploader()) {
      if(Params::getParam('action') == 'item_add' || Params::getParam('action') == 'item_edit' ){
         osc_enqueue_style('fine-uploader-css', osc_assets_url('js/fineuploader/fineuploader.css'));
         osc_enqueue_script('jquery-fineuploader');
      }
   }
   
   /* Theme Settings */
    function theme_metro_actions_admin() {
        switch( Params::getParam('action_specific') ) {
            case('settings'):
         
            $keyword_placeholder = Params::getParam('keyword_placeholder');
            Preference::newInstance()->update(array("s_value" => $keyword_placeholder),array("s_section" => "metro", "s_name" => "keyword_placeholder"));
            
            
            $footer_info = Params::getParam('footer_info',false, false, false);
            Preference::newInstance()->update(array("s_value" => $footer_info),array("s_section" => "metro", "s_name" => "footer_info"));
            
            $footer_link = Params::getParam('footer_link');
            Preference::newInstance()->update(array("s_value" => $footer_link),array("s_section" => "metro", "s_name" => "footer_link"));
            
            /* Ads */
            $search_list_ads = Params::getParam('search_list_ads',false, false, false);
            Preference::newInstance()->update(array("s_value" => $search_list_ads),array("s_section" => "metro", "s_name" => "search_list_ads"));
            $item_sidebar_ads = Params::getParam('item_sidebar_ads',false, false, false);
            Preference::newInstance()->update(array("s_value" => $item_sidebar_ads),array("s_section" => "metro", "s_name" => "item_sidebar_ads"));
            $home_sidebar_ads = Params::getParam('home_sidebar_ads',false, false, false);
            Preference::newInstance()->update(array("s_value" => $home_sidebar_ads),array("s_section" => "metro", "s_name" => "home_sidebar_ads"));
            
            /* Color Schemes */
            $color_scheme = Params::getParam('color_scheme');
            Preference::newInstance()->update(array("s_value" => $color_scheme),array("s_section" => "metro", "s_name" => "color_scheme"));
            $color_switcher = Params::getParam('color_switcher');
            Preference::newInstance()->update(array("s_value" => $color_switcher),array("s_section" => "metro", "s_name" => "color_switcher"));
            
            /* Category Icon */
            $icons = Params::getParam('id');
            $ids = array_keys($icons);
            foreach($ids as $id){
               osc_set_preference('cat-'.$id,$icons[$id],'metro');