Change (Library) Default Settings in Wordpress
Submitted by michaelwilliamautin on Mon, 02/19/2018 - 18:46
Forums:
Hello,
I would like to change the default settings for multichoice content.
I believe to have found the correct location in the multichoice.js file.
e.g.
behaviour: {
enableRetry: true,
But if I change any of the values from true to false nothing changes.
or e.g.
type: 'multi', I changed from 'auto'
but it still loads to Automatic.
Also I would like to have the "Display toolbar below content" unchecked by default.
Best, Michael
Content types:
thomasmars
Thu, 02/22/2018 - 14:26
Permalink
Hi Michael,Semantics are not
Hi Michael,
Semantics are not read from file every time, so just changing semantics in the file will not change it for content. For the plugin to read from file you would have to enable developer mode, this is strongly recommended against in a production environment, as these changes would be overwritten every time the library was updated among other things.
The recommended way of changing this, so that it will be compatible with new versions of the library is to implement a hook for the Multilpe Choice semantics. You can read more about that in the hooks / actions part of the wordpress customization guide.
Best regards, Thomas
michaelwilliamautin
Tue, 02/27/2018 - 12:57
Permalink
Perfect that was what I
Perfect that was what I needed :)
michaelwilliamautin
Wed, 02/28/2018 - 10:40
Permalink
No quite there yet.
Hi again Thomas, regretably it does not quite work as expected.
To be on the safe side I installed wordpress clean and also H5P.
I then installed the mod plugin from here to test. https://github.com/h5p/h5pmods-wordpress-plugin
My understanding would be that with the alter parameters of the multichoice each question should be prepoulated with <p>Generated at ' . time() . '.</p>
but that is not happening.
Also I noticed that the multichoice.js file has this set " question: "No question text provided" but when I add a new question it is just blank.
Best Michael
icc
Wed, 02/28/2018 - 13:19
Permalink
You can get the Display
You can get the Display toolbar below content always unchecked through the H5P Settings page.
For changing the defaults in the editor you want the h5pmods_alter_semantics() function.
To alter the content you want h5pmods_alter_parameters() function.
I just tested the h5pmods plugin and it appears to work fine. If you're unsure if the code/plugin is running try adding the following line to the function:
michaelwilliamautin
Wed, 02/28/2018 - 14:26
Permalink
Hi icc,I can confirm that the
Hi icc,
I can confirm that the plugin work thanks for the clarification on semantics and parameters.
I am afraid that I would need more detailed help because this faar exceed my abilities.
The only thing I am rather sure about is this line
if ($name === 'H5P.MultiChoice') {
But how I then address the correct fields no idea.
I attached an image of the three changes I would need.
Best, Michael
otacke
Sat, 03/03/2018 - 13:03
Permalink
Hi Michael!This function
Hi Michael!
This function should do what you require. Please take some time to understand how this works. And please note that this will not change the values in existing content, but just replace the default values for new content.
Best,
Oliver
michaelwilliamautin
Mon, 03/05/2018 - 10:31
Permalink
Many Many Many Thanks :)
Hi Oliver, thank you very much :) Especially for the detiled explanation. No I can make further changes if necessary.
For completeness and others maybe you could update your code and add:
add_action('h5p_alter_library_semantics', 'h5pmods_alter_semantics', 10, 4);
at the end. For many it may be obvious but it trough me off at first.
Michael
otacke
Mon, 03/05/2018 - 19:09
Permalink
Hi Michael!Well, I'm not
Hi Michael!
Well, I'm not replacing the hints in the documentation ;-) I added a comment and a line. In fact you can replace the 4 by a 2 in this case - just in case that you want to dig deeper ...
Best,
Oliver
tki
Wed, 03/07/2018 - 17:57
Permalink
Hi Oliver,Thank you very much
Hi Oliver,
Thank you very much for such a detailed explanation. I was able to add some modifications to MultipleChoice, but I'm struggling with modifications in Column. I've followed steps and check several times everything, but my changes are not applied.
Could you please let me know what is wrong in this code? I'm trying to make the separator disabled by default in Column.
Thanks!
otacke
Wed, 03/07/2018 - 19:13
Permalink
Hi tki!Your code has actually
Hi tki!
Your code has actually two flaws which you will notice if you inspect the semantics file of H5P.Columns a little closer. At the upper level, it doesn't have an attribute called 'fields' that you're trying to read with '$semantic_field->fields'. If you changed that to 'field', it would still would not word because then you're at the level of the group, but not of it's items. I guess this function will explain it better:
Best,
Oliver
tki
Wed, 03/07/2018 - 20:32
Permalink
Thanks Otacke for such a
Thanks Otacke for such a quick reply! I understand now much better the structure of semantics.json . However, when I'm appliyng your code, WP stops working. I found 1 missing closing } at the end, but it didn’t help.
otacke
Wed, 03/07/2018 - 20:54
Permalink
You will probably have to
You will probably have to check the php error log then. It's working well here.
tki
Wed, 03/07/2018 - 21:03
Permalink
Thanks! I'll try to check it
Thanks! I'll try to check it out!
tki
Wed, 03/07/2018 - 21:58
Permalink
I found all my problems. Now,
I found all my problems. Now, I can see the changes applied in Column, however it only works in English version of WP, when I'm switching back to French, these changes won't apply (see pics attached). Is there a way to bypass translation? Thank you!
otacke
Wed, 03/07/2018 - 22:36
Permalink
Hi tki!Great that you figured
Hi tki!
Great that you figured it out!
The translation issue sounds strange, but I have tried it myself and I can reproduce it. I don't think it should stop the overrides from working, and this might be a bug. I'll leave a note to a colleague who knows the inner workings of altering semantics better than I do.
Best,
Oliver
tki
Wed, 03/07/2018 - 23:44
Permalink
Thanks for confirming that! I
Thanks for confirming that! I’ve tried to apply this code (from: https://github.com/h5p/h5pmods-wordpress-plugin/blob/master/h5pmods.php):
and I have the same results, I can see the changed label only in English version, it's not applied in French.
otacke
Thu, 03/08/2018 - 00:09
Permalink
Hi tki!Yup. I had already
Hi tki!
Yup. I had already checked labels, too, in order to check the magnitude of that issue.
Best
Oliver
otacke
Thu, 03/08/2018 - 09:53
Permalink
Hi itk!I have created a
Hi itk!
I have created a ticket in our issue tracker system. You can track the progress there.
Best,
Oliver
michaelwilliamautin
Thu, 03/08/2018 - 13:58
Permalink
Unsubscribe
Just need to comment so I can save the unsubscribe.
tki
Thu, 03/08/2018 - 19:12
Permalink
Thank you Otacke! You rock!
Thank you Otacke! You rock!
otacke
Thu, 03/08/2018 - 21:31
Permalink
:-)
:-)
cpeterson
Sat, 03/10/2018 - 12:52
Permalink
h5pmods wordpress plugin master activation error
Hello ladies and gents.,
I installed the H5Pmods plugin and my wordpress installation vomited it bachup. Please see error and if anyone can help, it would be hughly appreciated.
Fatal error: Cannot redeclare h5pmods_alter_styles() (previously declared in /homepages/43/d724625128/htdocs/clickandbuilds/WordPress/MyCMS3/wp-content/plugins/h5pmods-wordpress-plugin-master/h5pmods.php:116) in /homepages/43/d724625128/htdocs/clickandbuilds/WordPress/MyCMS3/wp-content/plugins/h5pmods-wordpress-plugin-master/h5pmods.php on line 132
Best regards,
Crawford
otacke
Sat, 03/10/2018 - 13:28
Permalink
Hi Crawford!Since the error
Hi Crawford!
Since the error messages that you posted don't match with the latest original code of the plugin that I found on github, I guess you changed the code yourself or git the plugin code frome somewhere else?
The error messages tell you, that on line 132, you seem to have something like function h5pmods_alter_styles(...) {...}, but also the same thing on line 116. You cannot have functions with the same name here. You should e.g. rename the second one, but I guess you could also put it's contents in the first one if you want to alter the CSS in both.
cpeterson
Mon, 03/12/2018 - 18:47
Permalink
Error
Hi Otacke,
Thanks for responding. No, I did not change the code. My programming skills copy/paste or install ... design. LOL
Thank you for the update link. I'll go get it now and try it out.
Crawford
cpeterson
Sat, 03/17/2018 - 13:45
Permalink
I'm not getting h5pmods to work
Hi,
Is there a layman's instructional guide for setting up the h5pmods plugin?
I installed the plugin without errors. I also made, what I thought to be correct, edits to the h5pmods.php and created a blank "custom-h5p-stying.css" file in the h5pmods-wordpress-plugin-master folder
function h5pmods_alter_styles(&$styles, $libraries, $embed_type) {
$styles[] = (object) array(
// Path can be relative to wp-content/uploads/h5p or absolute.
'path' => 'https://efiusnet.com/wp-content/plugins/h5pmods-wordpress-plugin-master/...',
'version' => '?ver=1.3.7' // Cache buster
);
}
add_action('h5p_alter_library_styles', 'h5pmods_alter_styles', 10, 3);
I found this CSS online. Is there a way to modify this to remove the download button in the audio controller.
video::-internal-media-controls-download-button { display:none;} video::-webkit-media-controls-enclosure { overflow:hidden;} video::-webkit-media-controls-panel { width: calc(100%+30px);/* Adjust as needed */}
icc
Thu, 03/22/2018 - 16:44
Permalink
This might be a bit tricky
This might be a bit tricky the first time you do it, but once you understand how it works it should be easy to make these kinds of changes.
You should open the browser's console(Ctrl+Shift+J) and verify that the custom css file is loading(Network tab and filter on CSS).
Be aware that the browser may cache files so your changes won't show up, to avoid this you can check the Disable cache box in the Network tab, or settings for other browsers.
You can add a test rule like this to see if the .css file is actually working:
To disable the download button I think you are on the correct track:
https://stackoverflow.com/questions/41115801/in-chrome-55-prevent-showing-download-button-for-html-5-video/41136470#41136470