Okay
  Public Ticket #1643420
Autorize Editor to modify the logo
Closed

Comments

  •  4
    MissZougou started the conversation

    Hi again !

    I'd like to give the possibility to editor user to change the logo.

    I created a new role "admin-site" with User Role Editor plugin
    The role is based on Editor role with the capability 'edit_theme_options' added.

    Is it possible to give access to the panel "Logo" from "Theme Options", and just this panel ?

    Thanks again for your time



  •  347
    OrionThemes replied

    The theme uses the Redux framework for the option panel. All theme options are inside the recycle-plugin/admin/sections/general-layout.php

    I have never worked with permissions before in Redux, so I can't give you a definite answer if this is possible or not. A quick search on google showed that there is permission support: https://docs.reduxframework.com/core/fields/using-permissions/

    But the thing is, that if the user updates the plugin, all this customisation will be gone. Also we tend to add options with new updates, so preventing plugin updates is not something I can really recommend.

    Andrej 

  •  4
    MissZougou replied

    Tanks Andrej for your answer.
    I managed to do what i wanted : give access to Editor role to the LOGO section in THEME OPTIONS.

    Here are the 2 files of the Recycle plugin i modified :

    - /admin/options-init.php

    'page_permissions' => 'delete_others_pages'
    

    - /admin/sections/general-layout.php

    I added 'permissions' argument to each sections (Redux::setSection())

    for LOGO SECTION

    'permissions' => 'delete_others_pages', 

    for all others SECTIONS

    'permissions' => 'manage_options',
    

    and it's working great !

    Note : Of course, each time the plugin will be updated, i will have to reedit these 2 files.

    Thanks for your help

  •  347
    OrionThemes replied

    Great, I am glad it worked. 

    Thanks for valuable feedback!

    Andrej

  •  4
    MissZougou replied

    No prob, it might be usefull for some other users :)

    One quick question. The theme is not supporting tagline right ?
    I modified template 'header-widgetsfluid.php' to display the tagline with this :

    get_bloginfo ( 'description' );

    But again, id'like Editor role to have the ability to edit the tagline...
    Or Editor role have only access to one checkbox (display title and tagline) in Appearance -> Customize -> Identity...

    Do you have an idea how to achieve that ? I don't think this is relative to the theme options but I prefer asking...

  •  4
    MissZougou replied

    I'm trying to translate LOGO section in THEME OPTIONS.

    esc_html__('The theme will automatically change the logo to suit the background color of the header.', 'recycle'),

    I searched in LOCO TRANSLATE plugin -> themes -> recycle, i can't find anyhting...

  •  347
    OrionThemes replied

    Hi,

    Tagline:

    Tagline is not supported, adding it to header-widgetfluid.php will add it only to one of the headers. The second header template file is header-classic.php. 

    Alternative approach would be to copy the function orion_get_logo() from helpers.php (line 342 ) to your child theme's functions.php file and add tagline inside, so it would render with the logo function. 

    Both solutions are equally good.

    Tagline checkbox: 

    You'd need to add your own checkbox option, then check if checkbox is on or off. You can do this with redux, you've already modified the general-layout.php file in the plugin anyway.  

    But you could also avoid this, and just check if the tagline is empty or not:

    <?php 
    if ( get_bloginfo( 'description' ) ) :    
        <span class="tagline"> 
            <?php echo get_bloginfo( 'description' ); ?>
        </span>
    <?php endif;?>

    Translation:

    Theme options are located in a plugin (.../recycle-plugin/). Loco translate can translate it. I've used it to create the .pot file, which you can use as a template file for loco translate. Just copy it to /wp-content/plugins/recycle/plugin, then go to Loco Translate -> Plugins and create your language file for the recycle-plugin. 

    Kind regards,

    Andrej

    Attached files:  recycle.pot

  •  4
    MissZougou replied

    Again thank you for your big help !

    I created a new Redux section "Slogan" in recycle-plugin/admin/sections/general-layout.php
    1 field #slogan / type:text / validate:html

    Then i created a simple function get_slogan() in functions.php, and call this function in my header template used (header-widgetsfluid.php)

    So now, my user with Editor role can edit the tagline and the logo ^^

    Awesome ! +++

  •  4
    MissZougou replied

    To translate recycle-plugin : 

    - I uploaded your .pot file in recycle-plugin folder
    - I created a new language file (fran├žais)
    - test with translation of 'Logo Upload' => still in english

    I also tried to change :

    esc_html__('Logo Upload', 'recycle');

    with this : 

    esc_html__('Logo Upload', 'recycle-plugin');

    no change, still in english.

    What am i doing wrong ?

    Attached files:  recycle-panel-1.jpg
      recycle-panel-2.jpg
      recycle-panel-3.jpg

  •  347
    OrionThemes replied

    Hi,

    I've just tested it by creating a new language file and translation appeared:

    Here is step by step:

    You can additionally check couple of things:

    - Check if the site language is set to French in Settings -> General

    - Check if your current user has the language set to French in Users -> Your profile.

    Kind regards,
    Andrej

  •  4
    MissZougou replied

    Thanks, i tried to follow your instructions but no luck.

    But by creating a new language with your "recycle.pot" file, i got a warning, see attachment (only 5 strings avalaible)

    So, i tried in a different way :

    - rename "recycle.pot" into "recycle-plugin.pot"

    - upload in /wp-content/plugins/recycle/plugin

    - loco translate -> plugins -> recycle Theme plugin :
    new language : fran├žais
    location : system (languages/plugins/recycle-plugin-fr_FR.po)
    ==> no warning like before (506 strings found)

    - translate string "Logo upload" and button Save

    No luck yet

    In '/recycle-plugin/admin/sections/general-layout.php' :

    Change :

    'title'    => esc_html__('Logo Upload', 'recycle'),

    into this :

    'title'    => esc_html__('Logo Upload', 'recycle-plugin'),

    ==> Ok my text is finally translated ^^

    Also in location of the language, it had to be System (i tried Custom at first, and it didn't work).

    What do you think about this method ? Is it strange that i should rename the .pot file and change textdomains in template of the plugin ?

    Thanks for your time

    Attached files:  recyle-plugin-translate-warning-recycle.pot.jpg

  •  347
    OrionThemes replied

    Hi,

    Here is what I learned from this: 

    It seems that the text domain, if not defined elsewhere is the name of the folder. So we should be using recycle-plugin in this case, or define custom text-domain. 

    In Loco Translate, when you create (or edit) a template, there is an "Advanced" tab, under this tab you can set the text domain, file prefix and template file separately. 

    Here is how it is on my installation: 


    I actually thought this configuration is saved in the pot file, I was wrong however. It can be added as xml however (attached).

    We will improve this in the next update.
    For backward compatibility reasons, we will not change recycle to recycle-plugin, but will define a text-domain plugin header.

    Andrej

    Attached files:  loco.xml

  •  4
    MissZougou replied

    Ok. 

    so I should restart from fresh ? use "recycle.pot" and modify settings in advanced tabs like you did ?

    currently i'm using "recycle-plugin.pot" and have modified the texdomains in esc_html__()

    esc_html__('Logo Upload', 'recycle-plugin'),
  •  347
    OrionThemes replied

    Well you know what they say, don't fix it if it isn't broken.
    I think there is nothing wrong with how you solved it.

    The only problem I see is  that you will need to patch quite a lot of things, when you decide to upgrade the plugin in the future. But then on the other hand, you will need to patch this same file anyway due to custom permissions...

    If I were in your shoes, I'd just create a TODO list for future updating, because in couple of months, or a year later, I would definatly forget, what kind of patches I've done and why... 

    Cheers,
    Andrej

  •  4
    MissZougou replied

    Hihihi you're right !

    Don't worry, there's always...a TODO LIST for each of my project....too much sometimes ^o)

    Thanks for your awesome support 

  •  4
    MissZougou replied

    For info, the string "Will only display if no Logo image is selected." is missing in .pot file

  •  347
    OrionThemes replied

    I can't find this string on my development version. It is possible that this has already changed since last TF version.

    You can easily update your .pot template with Loco translate to match your version of files. Just make sure to set a higher limit for PHP file size in Loco translate settings, default is 100k, while the theme option settings file is 148k: