Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
384 views
in Plugins by

I am trying to follow @pupi1985 suggestions to build a plugin to allow only each user to publish in each own wall: http://www.question2answer.org/qa/43652/there-way-hack-wall-permission-order-allow-user-post-her-wall

1) The first part of the plugin seems to be working:

qa_register_plugin_overrides('caju-wall-overrides.php','qa_wall_error_html','Write on your wall');

and in caju-wall-overrides.php I override the function qa_wall_error_html as suggested in the previous question.

2) The second part is not working. I basically need to remove

<input name="wall" type="checkbox" value="1" checked="" class="qa-form-wide-checkbox">

that arises in user's profile edition. In order to do that I am including

qa_register_plugin_layer('caju-WYW-layer.php', 'Caju WYW Layer');

Inside caju-WYW-layer.php, I have

<?php
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
    header('Location: ../../');
    exit;
}


class qa_html_theme_layer extends qa_html_theme_base {
        function doctype() {
            unset($this->content['form_profile']['table']['wall']);
            qa_html_theme_base::doctype();
        }    
}

What is going wrong?

3 - The last part I also need to include this piece of css code in qa-styles.css

.qa-part-message-list .qa-error{
        margin-bottom: 5px;
    padding: 10px;
    color: #e74c3c;
}
.qa-part-message-list .qa-error a, .qa-warning a, .qa-notice a {
    color: #e74c3c;
    border-bottom: 1px dotted #fff;
}
.qa-part-message-list .qa-error a:hover, .qa-warning a:hover, .qa-notice a:hover {
    color: #e74c3c;
    border-bottom: 0;
}

.qa-part-message-list .qa-error {
    background: #fff;
    position: relative;
    z-index: 999;
}

and I have no idea how to do that. Can you help me learn this? I am trying to learn how to add new tools to Q2A without changing the core.

Q2A version: 1.7.0

1 Answer

+2 votes
by
selected by
 
Best answer

1. Done

2. Silly typo there. Considering you're using 1.7+, it is better to use the initialize() function instead of doctype(), as it is semantically more appropriate:

public function initialize() {
    if ($this->template === 'account') {
        unset($this->content['form_profile']['fields']['wall']);
    }
    parent::initialize();
}​

3. If, as you say, you just want to add that code to qa-styles.css then just paste it there.

If you want to include a custom CSS file that is added to the <head> tag:

public function initialize() {
    if (!isset($this->content['css_src'])) {
        $this->content['css_src'] = array();
    }
    $this->content['css_src'][] = qa_html(QA_HTML_THEME_LAYER_URLTOROOT . 'path-to-css-file-inside-your-plugin-directory.css');
    parent::initialize();
}​

If you want to add inline CSS:

public function initialize() {
    if (!isset($this->content['head_lines'])) {
        $this->content['head_lines'] = array();
    }
    $this->content['head_lines'][] = '<style>.some-class{color:red}</style>';
    parent::initialize();
}

...